ValueError:形状(3,600,600,1)和(1,600,600,1)

时间:2019-10-05 06:49:34

标签: python arrays numpy

我不明白自己在做什么错。我尝试了一切。

import imageio

img1 = imageio.imread('yan1.jpg')
img2 = imageio.imread('test.jpg')

array = np.asarray(img1)
arraytest = np.asarray(img2)


def sigmoid(x):
    return 1 / (1 + np.exp(-x))

training_inputs = np.array([array])

training_outputs = np.array([1]).T

syn_w = 2 * np.random.random((3,1)) - 1

for i in range(50000):
    input_layer = training_inputs
    outputs = sigmoid( np.dot(input_layer, syn_w) )

    err = training_outputs - outputs
    adjustments = np.dot( input_layer.T, err * (outputs * (1 - outputs)))

    syn_w += adjustments

new_inputs = np.array([arraytest])
output = sigmoid( np.dot(new_inputs, syn_w) )

print('Test : ')
print(output)

错误:

  

adjustments = np.dot( input_layer.T, err * (outputs * (1 - outputs))) File "<__array_function__ internals>", line 6, in dot ValueError: shapes (3,600,600,1) and (1,600,600,1) not aligned: 1 (dim 3) != 600 (dim 2)

0 个答案:

没有答案