def printMatrix(): name = input( 'Input matrix\'s name to be printed. (Read from ".mtrx" file)\n>>>') raw = IO.RAWReader() raw.open(p.DATA_PATH + name + '.mtrx') matrix = IO.getAMatrix(raw) IO.printprettyMatrix(matrix)
def feedNeuralNetworkbymtrx(MyNeuralNetwork): name = input('Input .mtrx\'s file name.\n') rawreader = IO.RAWReader() rawreader.open(p.DATA_PATH + name + '.mtrx') M = IO.getAMatrix(rawreader) np.set_printoptions(threshold=np.nan) np.set_printoptions(precision=3) np.set_printoptions(suppress=False) IO.printprettyMatrix(MyNeuralNetwork.feed(M)) pass
def feedNeuralNetwork(MyNeuralNetwork): # string = input('input "row(number of data amount)", "column(number of input layer\'s neuron size)"\n') # string = string + ' ' + input('And then input "elements" row after row.\n') string= '1 '+str(MyNeuralNetwork.LayerNeuronsCount[0])+' ' # Single set of data 1 * input size string = string+input('Input single data set.(split by space and press enter)\n') rawreader = IO.RAWReader() rawreader.openString(string) M = IO.getAMatrix(rawreader) IO.printprettyMatrix(MyNeuralNetwork.feed(M))
def loadfromFile(self, Filename): try: MyRAWReader = IO.RAWReader() MyRAWReader.open(p.SAVED_PATH + Filename + '.node') self.Name = Filename self.LayersCount = int(MyRAWReader.pop()) self.LayerNeuronsCount = [] self.Weight = [] self.Bias = [] # Get the LayersCount first and Initlalize LayerNeuronsCount, Weight and Bias for layer in range(0, self.LayersCount): self.LayerNeuronsCount.append(int(MyRAWReader.pop())) # Get each layer's neurons count one by one for layer in range(0, self.LayersCount - 1): self.Weight.append(IO.getAMatrix(MyRAWReader)) # Get each layer's weight one by one for layer in range(0, self.LayersCount - 1): self.Bias.append(IO.getAMatrix(MyRAWReader)) # Get each layer's bias one by one except: print('warning: Loading ' + Filename + '.node error!')