fpgasystems / spooNN

FPGA-based neural network inference project with an end-to-end approach (from training to implementation to deployment)
GNU Affero General Public License v3.0
259 stars 74 forks source link

How to get txt file from npy file #37

Closed toebees closed 3 years ago

toebees commented 3 years ago

Hello. First, thank you for providing this code. I am having a problem with getting the txt file for running on Ultra96 (V2 in my case). I completed the training phase and got the resulting npy file. However, this file has a different format compared to the txt file that I need to feed into the Ultra96 board. It would be reaaaalllly helpful if you provided an answer.

first few lines of weights.npy file: 'conv1/W:0': array([[[[ 2.86133230e-01, 6.15961850e-01, -3.73895466e-01, 6.71454489e-01, 2.47721091e-01, -4.28864866e-01, 3.44760984e-01, -5.31071685e-02, 3.22882444e-01, 2.30810687e-01, 4.35990751e-01, -1.39825409e-02, -3.28335822e-01, 7.10032821e-01, -5.43806911e-01, 9.81799662e-02]

first few lines of the txt file you provided in your submissions folder: layer: 0 total_iterations: 360 0x070DCD1810DBA55020C1048A20E5651229160DB729962DF54FFDED0E2866F0020 0x02ED451A2240D5EF6D992BFF703446D99B34D75BE0F6B08892189D2C408B2F767 0 0 0

How can I change my current npy file into the corresponding txt file? Thanks in advance.

toebees commented 3 years ago

Btw, I got the npy file by using your recthalfsqznet - training code. I trained it on custom data and dumped weights to get the npy file.

kaankara commented 3 years ago

This is done here: https://github.com/fpgasystems/spooNN/blob/master/recthalfsqznet/hls/halfsqueezenet_folded.cpp, starting from line 707. Compile this and run the default test (input does not matter, it will write out the weights from "../training/halfsqueezenet-params.h".

toebees commented 3 years ago

Thank you so much!! I'll try it and update on how it goes soon.

toebees commented 3 years ago

Thank you so much for your help. It's working now!