Search code examples
pythonclasspandasnonetype

Within Pandas why is one array filled with 0's and the other a nonetype?


class NeuralNetwork(object):

 def __init__(self, data):    
      self.data = data

 def scan(self):
      print(self.data)
      print(self.data['AMZN'].shape)

 def create_layer(self):
      layer = np.zeros(shape = (self.data['AMZN'].shape[1], 10))
      print(layer)
      print(layer.shape)







 a1 = sigmoid(7)
 print a1



if __name__ == "__main__":
 #NeuralNetwork([3,2]).scan()
 #network = NeuralNetwork(dataread.test_run())
 network = NeuralNetwork(dataread.test_run())
 print (network.create_layer())
 layer1 = network.create_layer()
 print (layer1)
 #print (network.data['AMZN'].shape)
 #print (np.dot(network.data['AMZN'], layer1))

My question here is why is it that within the class when I print out the layer tha I set to be a 12 x 10 array of 0's it prints that out, but when I go to recreate it as layer1 = network.create_layer() it outputs a None? Shouldn't they be the same thing?


Solution

  • create_layer needs to either return something, or change the object somehow.

    Like this:

     def create_layer(self):
          layer = np.zeros(shape = (self.data['AMZN'].shape[1], 10))
          # print(layer)
          # print(layer.shape)
          return layer