2
我使用theano
函數,並且想要使用givens
來迭代所有輸入樣本。代碼如下:Theano函數通過'givens'屬性引發ValueError
index = T.scalar('index')
train_set = np.array([[0.2, 0.5, 0.01], [0.3, 0.91, 0.4], [0.1, 0.7, 0.22],
[0.7, 0.54, 0.2], [0.1, 0.12, 0.3], [0.2, 0.52, 0.1],
[0.12, 0.08, 0.4], [0.02, 0.7, 0.22], [0.71, 0.5, 0.2],
[0.1, 0.42, 0.63]])
train = function(inputs=[index], outputs=cost, updates=updates,
givens={x: train_set[index]})
它最終會引發錯誤:
ValueError: setting an array element with a sequence.
你能告訴我爲什麼,以及如何解決這個問題?
可能重複[ ValueError:使用序列設置數組元素](http://stackoverflow.com/questions/4674473/valueerror-setting-an-array-element-with-a-sequence) – aIKid
我不認爲它是重複的問題你提供的 – BoscoTsang
這個錯誤是一個普遍的錯誤,並且在我關聯的qeustion的答案中提到了原因。 – aIKid