28. Perceptron [¨58 Rosenblatt]
! 圻尖
僥返A
1. 嶷みベクトルを w = (0, . . ., 0) で兜豚晒
2. F壓の嶷みでの登協Y惚 g
3. 云栖の屎しい登協Y惚 a ( {1, ?1}
4. a , g > 0 なら登協撹孔 or フィ`ドバック
登協: 嶷み w と秘薦 p の坪e (の屎)
? w , p
フィ`ドバック
? 屎しいY惚の鬚に秘薦蛍だけ嶷みを厚仟
w := w + ap
29. Perceptronのgなg廾
sub weights { shift->{weights} ||= {} }
sub feedback {
my ($self, $ps, $ad) = @_;
$self->weights->{$_} += $ad * $ps->{$_} for keys %$ps;
}
sub learn {
my ($self, $ps, $ad) = @_;
my $g = $self->guess($ps) || 0;
$self->feedback($ps, $ad) unless $g * $ad > 0;
}
sub guess {
my ($self, $ps) = @_;
my $weights = $self->weights || {};
return sum map {
($weights->{$_} || 0) * $ps->{$_};
} keys %$ps;
}