TypeError: Cannot interpret '4' as a data type
TypeError: Cannot interpret '4' as a data type
我正在尝试学习神经网络。以下是代码。我收到错误“TypeError:无法将‘4’解释为数据类型”,谁能帮我找出错误?
import numpy as np
inputs = [[1, 2 , 3, 2.5],
[2, 5, 9, 10],
[5, 1, 2, 7],
[3, 2, 1, 4],
[1,1.5, 7, 8]]
class layer_dense:
def __init__ (self, n_inputs, m_neurons):
self.weights= np.random.rand(n_inputs, m_neurons)
self.biases= np.zeros(1, m_neurons)
def forward (self, inputs):
self.output= np.dot(inputs, self.weights)+self.biases
layer1 = layer_dense(4, 4)
layer2 = layer_dense(5,2)
layer1.forward(inputs)
layer2.forward(layer1.output)
print(layer2.output)
零的签名如下:
numpy.zeros(shape, dtype=float, order='C')
形状参数应以整数或多个整数的元组形式提供。您收到的错误是由于 4 被解释为 dtype。
numpy.zeros(shape, dtype=float, order='C')
第二个参数应该是数据类型而不是数字
我正在尝试学习神经网络。以下是代码。我收到错误“TypeError:无法将‘4’解释为数据类型”,谁能帮我找出错误?
import numpy as np
inputs = [[1, 2 , 3, 2.5],
[2, 5, 9, 10],
[5, 1, 2, 7],
[3, 2, 1, 4],
[1,1.5, 7, 8]]
class layer_dense:
def __init__ (self, n_inputs, m_neurons):
self.weights= np.random.rand(n_inputs, m_neurons)
self.biases= np.zeros(1, m_neurons)
def forward (self, inputs):
self.output= np.dot(inputs, self.weights)+self.biases
layer1 = layer_dense(4, 4)
layer2 = layer_dense(5,2)
layer1.forward(inputs)
layer2.forward(layer1.output)
print(layer2.output)
零的签名如下:
numpy.zeros(shape, dtype=float, order='C')
形状参数应以整数或多个整数的元组形式提供。您收到的错误是由于 4 被解释为 dtype。
numpy.zeros(shape, dtype=float, order='C')
第二个参数应该是数据类型而不是数字