简体   繁体   English

操作数不能与形状一起广播

[英]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 ,但仍尝试将数据集变量xsom.winner()方法一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 操作数不能一起广播 - Operands could not broadcast together 残差网络:操作数无法与形状 (128, 128, 16) (126, 126, 16) 一起广播 - Residual Network : Operands could not be broadcast together with shapes (128, 128, 16) (126, 126, 16) StandardScaler ValueError:操作数无法与形状一起广播 (75000,3) (50,) (75000,3) - StandardScaler ValueError: operands could not be broadcast together with shapes (75000,3) (50,) (75000,3) ValueError: 操作数不能与形状一起广播 (256, 256, 64) (256, 256, 3) - ValueError: Operands could not be broadcast together with shapes (256, 256, 64) (256, 256, 3) 矩阵减法 | ValueError:操作数无法与形状一起广播 (1,30) (30,455) - Matrix Subtraction | ValueError: operands could not be broadcast together with shapes (1,30) (30,455) 在神经网络中应用最小批处理时,在epoch_cost中出现错误“操作数不能与形状(32,)(5,)(32,)一起广播” - Getting error in epoch_cost “operands could not be broadcast together with shapes (32,) (5,) (32,) ” while applying minibatches in neural net Numpy dot function:操作数不能在 MLP 中一起广播 - Numpy dot function: operands could not be broadcast together in MLP 有没有办法将不同形状的 ndarray 广播到单个 ndarray 中? - Is there a way to broadcast ndarray of different shapes into a single ndarray? valueError:无法将输入数组从形状(46105,1)广播到形状(46105)? - valueError: could not broadcast input array from shape (46105,1) into shape (46105)? 无法在深度学习工作室深度认知中将输入数组从形状(7,3)广播到形状(32,3) - could not broadcast input array from shape (7,3) into shape (32,3) in Deep learning Studio Deep cognition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM