1 of 8

Cookbook for Practice 7.1

Cong Li 李聪

实践7.1攻略

2 of 8

Margin Parameter 间距参数

In ‘perceptron.py’, in the initialization function of the class ‘BinaryPerceptron’, pass in a new variable for the margin parameter, & use a member variable to store it

在“perceptron.py”文件里,为“BinaryPerceptron”类型的初始化函数传入一个新的间距参数变量,并用一个成员变量来存储之

3 of 8

Calculate Confidence Threshold �计算置信度阈值

In the same class, add a member function to calculate the maximum length of the training samples & the confidence threshold. Store them in 2 member variables

在这个类型里,加入一个新的成员函数,计算训练数据的最大长度及置信度阈值,并用两个成员变量来存储

Calculate maximum length

计算最大长度

4 of 8

Calculate Confidence Threshold �计算置信度阈值

In the same class, add a member function to calculate the maximum length of the training samples & the confidence threshold. Store them in 2 member variables

在这个类型里,加入一个新的成员函数,计算训练数据的最大长度及置信度阈值,并用两个成员变量来存储

Calculate confidence threshold

计算置信度阈值

5 of 8

Training 训练

In training, first call the newly written member function

在训练时,先调用新写的成员函数

Next, change the parameter update condition as well as the way to update the bias term

然后修改参数更新的条件以及修改偏向的方式

New parameter update condition

新的参数更新条件

6 of 8

Training 训练

In training, first call the newly written member function

在训练时,先调用新写的成员函数

Next, change the parameter update condition as well as the way to update the bias term

然后修改参数更新的条件以及修改偏向的方式

New way to update the bias term

新的修改偏向的方式

7 of 8

Run It 运行之

Based on Practice 6.1, in ‘test.py’, pass in a margin parameter in creating an instance of class ‘BinaryPerceptron’

基于实践6.1,在“test.py”中,在创建一个“BinaryPerceptron”类型的实例时传入一个间隔参数

Run it w/ the training size of 20

以训练数据量20运行该程序

8 of 8

The End