• Valiarnt

    This is the second file.
    The data file is located here, and just sits in the same folder.

    import NeuralNetwork as nn
    import numpy as np
    #Data collection
    with np.load('mnist.npz') as data:
    training_images = data['training_images']
    print(training_images.shape)
    training_labels = data['training_labels']
    print(training_labels.shape)

    layer_sizes = (784,5,10)

    net = nn.NeuralNetwork(layer_sizes)
    prediction = net.predict(training_images[:1])
    #changing this value to a single integer does not give any problems, passing in multiple values does however. I’m thinking I need to iterate on the outside of the function rather than on the inside.

    print('Prediction Shape: ')
    print(prediction.shape)

    posted in Pythonista read more
  • Valiarnt

    I have this project split into 2 files, this is the first.
    I am definitely getting matrices with the wrong sizes.

    import numpy as np

    class NeuralNetwork:

    def __init__(self, layer_sizes ):
        #layer_sizes = (784,5,10)
        weight_shapes = [(a,b) for a,b in zip(layer_sizes[1:],layer_sizes[:-1])]
        print(weight_shapes) #prints (5,784),(10,5)
        self.weights = [np.random.standard_normal(s)/s[0]**.5 for s in weight_shapes]
        self.biases = [np.zeros((s,1))for s in layer_sizes[1:]]
        
    def predict(self, a):
        for w,b in zip(self.weights,self.biases):
            g = np.array([])
            for a in a:
                a = self.activation(np.dot(w, a))+b
                g = np.append(g,a)
                print(" Data Set Processed")
            print('Result of Activation Function')
        return g
            
    @staticmethod
    def activation(x):
        return 1/(1+ np.exp(-x))

    posted in Pythonista read more
  • Valiarnt

    Hey, I just recently got pythonista, and love the convenience of it. I’m not a super experienced coder, and I think I’m looking for an alternative to numpy’s matmul, which does not seem to be present in the numpy native to the app. The ‘@‘ operator present in base Python does not accept ndarray datatypes. I think I might also be having another issue with my code, completely separate, but any piece of the puzzle is a step forward.

    The matrices I am multiplying are 2-D, so np.dot() almost worked, but it started giving me a completely different error. As I pass in multiple matrices, it passes one large 3-D matrix that no longer works for np.dot(). Something with my iterating must be off.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!