omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Valiarnt

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    Valiarnt

    @Valiarnt

    0
    Reputation
    294
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Valiarnt Unfollow Follow

    Latest posts made by Valiarnt

    • RE: Matrix Multiplication/ matmul alternative

      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
      Valiarnt
      Valiarnt
    • RE: Matrix Multiplication/ matmul alternative

      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
      Valiarnt
      Valiarnt
    • Matrix Multiplication/ matmul alternative

      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
      Valiarnt
      Valiarnt