【发布时间】:2020-04-09 13:40:37
【问题描述】:
import numpy
HL1_neurons = 15
input_HL1_weights = numpy.random.uniform(low=-0.1, high=0.1,size=(15, HL1_neurons))
output_neurons = 1
HL2_output_weights = numpy.random.uniform(low=-0.1, high=0.1,size=(HL1_neurons, 1))
weights = numpy.array([input_HL1_weights,HL2_output_weights])
在执行代码时 HL1_neurons 接受 15 以外的任何数字
如果是 15 则显示以下错误,请在这方面帮助我
ValueError Traceback (most recent call last)
<ipython-input-15-97fe596c0407> in <module>
4 output_neurons = 1
5 HL2_output_weights = numpy.random.uniform(low=-0.1, high=0.1,size=(HL1_neurons, 1))
----> 6 weights = numpy.array([input_HL1_weights.astype(object),HL2_output_weights.astype(object)])
ValueError: could not broadcast input array from shape (15,15) into shape (15)
【问题讨论】:
-
你认为
numpy.array([input_HL1_weights,HL2_output_weights])会做什么?
标签: python numpy neural-network