josephjaspers / blackcat_tensors

Matrix-Vector Library Designed for Neural Network Construction. cuda (gpu) support, openmp (multithreaded cpu) support, partial support of BLAS, expression template based implementation PTX code generation identical to hand written kernels, and support for auto-differentiation
12 stars 4 forks source link

Add saving/loading to Neural Network module #25

Closed josephjaspers closed 5 years ago

josephjaspers commented 5 years ago

need the trained net support save and load net, as the net at https://github.com/Artelnics/OpenNN.main supprot function:1、

save the trained model load the saved model trained to predict

josephjaspers commented 5 years ago

Added save/load https://github.com/josephjaspers/BlackCat_Tensors/commit/520b2b71eff5e5772c8754a1282e97ff3affd9bc

> (base) joseph@joseph-G751JY:~/BlackCat_Tensors/BlackCat_Tensors/examples/mnist_test/forward_net$ cat architecture.yaml 
> FeedForward:
>   inputs: 784
>   outputs: 256
> Logistic:
>   inputs: 256
>   outputs: 256
> FeedForward:
>   inputs: 256
>   outputs: 10
> SoftMax:
>   inputs: 10
>   outputs: 10
> OutputLayer:
>   inputs: 10
>   outputs: 10
> (base) joseph@joseph-G751JY:~/BlackCat_Tensors/BlackCat_Tensors/examples/mnist_test/forward_net$ ls l0_FeedForward/
> b.vec  w.mat
> (base) joseph@joseph-G751JY:~/BlackCat_Tensors/BlackCat_Tensors/examples/mnist_test/forward_net$ ls l2_FeedForward/
> b.vec  w.mat
> 

The '.vec' and '.mat' files are really just csv files. (The .vec files have only 1 row).

You may save a model by calling "network.save(directory)" You may load a model by calling "network.load(directory)"

save will create a directory if it does not exist. This still needs to be tested on Windows.

Update: Tested with Windows/ and added fixes as of: https://github.com/josephjaspers/BlackCat_Tensors/commit/b95d7dfe63b337e05daac75c067c162a7af713e3

josephjaspers commented 5 years ago

Added and tested.