[英]operands could not be broadcast together with shapes
I have used this code but it showing me error. 我使用过此代码,但它显示错误。 Help me solve this. 帮我解决这个问题。
som=MiniSom(x=10,y=10,input_len=15,sigma=1.0,learning_rate=0.5)
som.random_weights_init(x)
som.train_random(data=x,num_iteration=100)
from pylab import bone, pcolor, colorbar, plot, show
bone()
pcolor(som.distance_map().T)
colorbar()
markers = ['o', 's']
colors = ['r', 'g']
for i, x1 in enumerate(x):
w = som.winner(x)
plot(w[0] + 0.5,
w[1] + 0.5,
markers[y[i]],
markeredgecolor = colors[y[i]],
markerfacecolor = 'None',
markersize = 10,
markeredgewidth = 2)
show()
The line w = som.winner(x)
should be replaced with w = som.winner(x1)
线w = som.winner(x)
应替换为w = som.winner(x1)
MiniSom.winner()
method computes the coordinates of the winning neuron for the sample x, where sample x is one single row of your dataset, and the corresponding variable name in your code is x1 . MiniSom.winner()
方法计算样本x的获胜神经元的坐标,其中样本x是数据集的一行 ,并且代码中的相应变量名称是x1 。
You are iterating x1
over rows of x, however still trying to use the dataset variable x with som.winner()
method. 您正在x1
行上迭代x1
,但仍尝试将数据集变量x与som.winner()
方法一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.