Package: neowise
neowiseDocumentationSteps to train your own Neural Network usingneowiseInstall andimport neowise as nwGet your data and pre-process it. Yourdatashould be in the dimensions as(number_of_examples, number_of_features)andlabelsshould have(number_of_output_units, number_of examples)as its dimensions.
This is a must, any changes here would raise errors!Create a model by callingmodel = nw.Model(your_train_data, your_train_labels, your_test_data, your_test_labels, your_crossval_data, your_crossval_labels)If you do not have Cross Validation data, enterNonefor the last two arguments.Add layers to your model bymodel.add(layer_name,num_inputs,num_outputs,activation_function,dropout), where you give a unique name to each of your layers so that you know what type of layer it is. Example fordenselayer, if it is your first layer, name itdense1. Enter the number of inputs to that layer, innum_inputsand number of units for that layer innum_outputs.
For activation_function useany of the following supported activation functions["relu", "sigmoid", "tanh", "softmax", "sine"].
To prevent overflows and nans, we suggest that if you use a softmax classifier, to set the activation of the previous layer of the output layer as"tanh"as it squishes values between -1 and 1, thus preventing catastrophe. If you want to use Dropout, set thedropoutanywhere between 0 and 1. Else, the default value is taken as 1, i.e no Dropout.Just to be sure of your architecture and to know the amount of parameters that'll be trained callmodel.summary()which uses prettytable to print out a summary of your architecture.Train your model usingmodel.fit(your_train_data, your_train_labels, learning_rate, number_of_iterations, optimizer, problem_type, mini_batch_size, regularization_type, lambda, learning_rate_decay), where you enter your training data, choose the learning rate, set the number of iterations to train for, choose which type of optimizer you want from["GD" for Gradient Descent, "Momentum" for Gradient Descent using Momentum, "RMSprop" for Root Mean Square Propagation, "Adam" for Adaptive Moment Estimation]If you want to train usingBatch Gradient Descent, choose"GD"asoptimizerand set themini_batch_sizeto the total number of examples in your training data and if you want to train usingStochastic Gradient Descent, choose"GD"asoptimizerand setmini_batch_sizeto 1. Forproblem_typechoose any of the currently supported tasks["Binary" for Binary Classification Tasks, "Multi" for Multi Class Classification Tasks]Setmini_batch_sizeto the size you want each of your mini batches to be and be sure that this value is less than the total number of examples you have. If you want to use L1 or L2 regularization choose from["L1" for L1 Regularization and "L2" for L2 Regularization]and set the regularization parameterlambda. If you want yourlearning_rateto not be constant and be decreasing as the training progresses, setalpha_decayto TrueTest the model on your test data by callingmodel.test(your_test_data, your_test_labels, problem_type)on your training data and setproblem_typeas you did formodel.fit. This displays a prettytable with precision, recall and f1 scores and its accuracy on the test data.For plotting the costs and accuracy vs number of iterations, callmodel.plot(type_function, animate, directory, frequency)and settype_functionto"Cost"if you want to plot costs vs number of iterations and"Accuracy"for accuracy vs number of iterations. If you want to create animated graphs, setanimateto True and specify the directory in which you want to save the plots indirectoryand set the frequency with which the graphs should update infrequency, then feed those images to a GIF creator to create animated plots.To save the model, callmodel.save_model(file_name)and specify the directory in which you want to save the model with the name of the model with the extension .h5 infilenameTo load a previously saved model, create a new model be callingsaved_model =  nw.Model(your_train_data, your_train_labels, your_test_data, your_test_labels, your_crossval_data, your_crossval_labels), where these are the same data on which model was trained on.Call saved_model.load_model(file_name)to load the model from the directory specified infile_nameThese are the functionalities thatneowiseoffers. For detailed doc_strings visitSource Codeto find more about the project!