Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Cannot interpret '4' as a data type

I am trying to learn Neural Network. Following is the code. I am getting the error 'TypeError: Cannot interpret '4' as a data type" Can anyone please help me identifying the mistake?

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)
like image 630
Himanshu Gaur Avatar asked Jan 12 '21 08:01

Himanshu Gaur


Video Answer


1 Answers

Per function description

numpy.zeros(shape, dtype=float, order='C')

The 2nd parameter should be data type and not a number

like image 90
Nir Elbaz Avatar answered Sep 16 '22 14:09

Nir Elbaz