首页 >
> 详细

ECS 170: Spring 2022

Homework Assignment 5

Due Date:

No later than Thursday, June 2, 9:15pm PDT. (You don't have to wait that long, and you

shouldn't. You have a final exam the next day. But I understand that some of you prefer to wait

until the last minute.)

You are expected to do this assignment on your own, not with another person.

This assignment looks really long. Don't panic. Most of this document is just examples.

The assignment:

Recall the perceptron learning model described in Lectures 16 and 17. Your task is to use Python

to write a function that implements the perceptron described in those lectures. Your function

should be named perceptron.

Your function should expect five arguments, in this order, left-to-right:

A number representing the threshold

A number representing the adjustment factor

A list of numbers representing the initial weights on the inputs

A list of examples for training the perceptron

A number representing the number of passes the perceptron should make through

the list of examples

Let’s map these descriptions onto the actual values used in the example:

In the example, the threshold was 0.5

The adjustment factor was 0.1

If contained in a list, the initial weights were [-0.5, 0, 0.5, 0, -0.5]

The list of examples was: [[True, [1,1,1,1,0]],

[False, [1,1,1,1,1]],

[False, [0,0,0,0,0]],

[False, [0,0,1,1,0]],

[False, [1,0,1,0,1]],

[False, [1,0,1,0,0]],

[False, [0,1,0,1,1]],

[False, [0,1,0,1,0]],

[False, [0,0,1,0,0]],

[False, [0,0,0,1,0]]]

The number of passes through the list of examples was 4

Each example in the list of examples has two parts. The first part (True or False) indicates

whether this example is a positive example (True) of the concept to be learned or a negative

example (False). The second part is a list of 1’s or 0’s. This list (the 1's and 0's) must be the same

length as the list of initial weights.

Now let’s say that the variable weights is bound to the list of weights shown above, and that the

variable examples is bound to that list of examples above. If you write your function exactly like

I did, then when your function is called like this:

>>> perceptron(0.5, 0.1, weights, examples, 4)

your function would print the following output (sorry, it’s really long, just like in Lecture 17):

Starting weights: [-0.5, 0, 0.5, 0, -0.5]

Threshold: 0.5 Adjustment: 0.1

Pass 1

inputs: [1, 1, 1, 1, 0]

prediction: False answer: True

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [1, 1, 1, 1, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [0, 0, 0, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [0, 0, 1, 1, 0]

prediction: True answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [1, 0, 1, 0, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [1, 0, 1, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 1, 0, 1, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 1, 0, 1, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 0, 1, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 0, 0, 1, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-21:00
- 微信：codinghelp

- Fit5217辅导、Python程序语言辅导 2022-05-31
- 辅导ecs 170 Introduction To Artificial... 2022-05-31
- 辅导ecs 170 Homework Assignment 5 2022-05-31
- Fit 5003 Software Security辅导 2022-05-30
- 辅导cse 101 Data Structures And Algori... 2022-05-30
- 辅导econ7150、辅导java，Python编程 2022-05-30
- Econ7150编程辅导 讲解 S1 2022 2022-05-29
- 讲解cse 101 程序 辅导 Data Structures 2022-05-29
- 辅导fit 5003 Software Security 2022-05-29
- Stat7055 Introductory Statistics For B... 2022-05-28
- Assignment 3 Description: Computer Sy... 2022-05-28
- 辅导laboratory 程序、辅导program编程 2022-05-28
- 讲解eece 1080C Programming For Ece 2022-05-28
- Comp10002 Foundations Of Algorithms辅导... 2022-05-28
- 辅导 Swen30006、辅导java/C++编程 2022-05-28
- Comp326讲解导、辅导python，Java程序 2022-05-28
- 辅导 Dungeon Crawler C++ - Assignment ... 2022-05-27
- 辅导mast30025 Linear Statistical Model... 2022-05-27
- Prog2002辅导、辅导sql语言编程 2022-05-26
- 辅导 Info411/911 Data Mining Knowledge... 2022-05-26