Package: phidnet
Phidnet1. Introduction to phidnetPhidnet is a library developed for neural network construction for deep learning, machine learning, and statistics.2. Install phidnetpip install phidnetPyPI:https://pypi.org/project/phidnet/GitHub:https://github.com/Intipy/phidnet3. Requirements of phidnetnumpymatplotlib4. Use phidnetImport phidnetimport phidnetNumpyAll data, such as matrix and vector, must be converted to numpy array object.Will be replaced by the built-in matrix library of the phidnet.Configuration of the Phidnetphidnet.activationphidnet.optimizerphidnet.loadphidnet.matrixphidnet.setphidnet.one_hot_encodephidnet.modelDefine activation functionSigmoid = phidnet.activation.Sigmoid()Relu = phidnet.activation.Relu()ectDefine optimizerSGD = phidnet.optimizer.SGD(lr=0.01)  # lr: learning rateMomentum = phidnet.optimizer.Momentum(lr=0.01, momentum=0.9)AdaGrad = phidnet.optimizer.AdaGrad(lr=0.01)Set layerphidnet.set.layer(784)phidnet.set.layer(200, activation=Sigmoid)phidnet.set.layer(10, activation=Sigmoid)If you did not set the activation function, that layer becomes input layer(Input layer does not have activation function.) and if you want to build hidden & output layer, you need to set activation function.Compile neural networkphidnet.set.compile(input=X, target=T)If you built the model, you can compile that model with setting input and output data.Set test datasetphidnet.set.test(input=X_test, target=T_test)If you want to calculate loss of test dataset(val_loss=True), you need to set this.Fit modelphidnet.model.fit(epoch=30, optimizer=SGD, batch=5000, val_loss=True, print_rate=2, save=True)In the example, train the model for epoch.SGD is the instance of phidnet.optimizer.SGD() class.Batch size is 5000.val_loss is loss of test dataset. This helps prevent overfitting. but, calculating this makes the fitting slow.Every 2 epoch, print the loss and accuracy of model(print rate).Predictpredicted = phidnet.model.predict(input, exponential=True, precision=2)In the example, the model returns the predicted value in the predicted variable. If exponential= is True, the model returns exponential representation value like 1e-6. When exponential=False, The model returns the value represented by the decimal like 0.018193. The model returns precise values as set to precision. When output is 0.27177211, precision=3, output is 0.271.SaveYou can save the model with .pickle file.phidnet.save.model('saved_model')It saves trained model in current directory.phidnet.save.model('saved_model', dir='C:\examples')It saves trained model in C:\examples directory.Loadphidnet.load.model('C:\examples\saved_model.pickle')You can load trained model.View fittingphidnet.model.show_loss()It shows a change in loss and validation loss.phidnet.model.show_accuracy()It shows a change in accuracy.One hot encodingphidnet.one_hot_encode.encode(number, length=length)phidnet.one_hot_encode.encode(3, length=5)   # [0, 0, 0, 1, 0]phidnet.one_hot_encode.encode_array(array, length=length)phidnet.one_hot_encode.encode_array([[1], [2], [3]], length=5)   # [[0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0]]phidnet.one_hot_encode.get_number(one_hot_encoded)phidnet.one_hot_encode.get_number([0, 0, 1, 0, 0])   # 2Pre-prepared datasetsX, T, X_test, T_test = phidnet.datasets.mnist.load()It loads mnist dataset with 1d shape. (784)X, T, X_test, T_test = phidnet.datasets.mnist.load_2d()It loads mnist dataset with 2d shape. (28, 28)5. Use phidnet matrixConverting to matrixmat = phidnet.array(list)Add, Multiplication, SubtractionEqual to other classes of operationsmat1 + mat2, mat1 - mat2, mat1 * mat2mat + 1, mat * 2, mat / 3Dot productphidnet.matrix.dot(mat1, mat2)Index of matrixIf you used a regular Python index, it is not suitable for two-dimensional arrays.
For example, [1][2] does not point to row 1 and column 2. A two-dimensional array is a shape with an array in array, and Python views the array as one element.The solution is to use the indexing, slicing functions built into the phidnet.Python index: mat[1][2] (does not point to row 1, column 2)Phidnet index: mat("1,2") (point to row 1, column 2)Python slicing: mat[1:3][:8] (does not point row 1-2, column 0-7)Phidnet slicing: mat["1:3,:8"] (point row 1-2, column 0-7)Slicing of matrix(by index)sliced_matrix = phidnet.matrix.slice_full(mat, row_start, row_end, column_start, column_end)sliced_matrix = phidnet.matrix.slice_full(mat, 1, 2, 1, 1)1-2 row, 1-1 column (0 based index)Slicing of matrix(by python slicing)sliced_matrix = mat["slicing with string"]sliced_matrix = mat["1:3,1:2"]1-2 row, 1-1 column (0 based index)sliced_matrix = mat[",1:2"]all row, 1-1 column (0 based index)Transpose matrixtransposed_matrix = phidnet.Matrix.trans(mat)transposed_matrix = mat.trans()Mapdef function(x): return 2*xmapped_matrix = phidnet.Matrix.map(mat, function)Powerpow_matrix = mat ** nmat^n (for every element in matrix)Else..6. Use phidnet convolution neural networkSet layer..writing..7. Use phidnet recurrent neural networkSet layer..writing..8. Example phidnetRefer to examples for details.