hanbt / learn_dl

Deep learning algorithms source code for beginners
Apache License 2.0
1.19k stars 988 forks source link

感知机在python3环境下无法运行 #36

Closed hemaojie closed 5 years ago

hemaojie commented 5 years ago

在python3下运行 报错map(lambda (x, w): x * w, ^ SyntaxError: invalid syntax 不知为何?

endrol commented 5 years ago

python3 不支持lambda输入tuple

xinghalo commented 5 years ago

修改三个地方: 1 lambda (x,w):xw 替换成 lambda x : x[0]x[1] 2 reduce 增加引用 from functools import reduce 3 梯度更新map返回的不是list,修改成:self.weights = [w + rate delta x for (x, w) in zip(input_vec, self.weights)]

hanbt commented 5 years ago

fixed