Comments (8)
Hi passiduck,
Thanks for your interest. The simple answer is you have to use bias in both conv/dense layers.
This is restricted by the backend which is the CMSIS-NN.
Any reason you dont want to use bias? I might add this feature later if it is necessary.
Thanks,
Jianjia
from nnom.
Thanks for the quick reply.
I tried to use an existing trained model. Also beta in BatchNormalization works the same way, I read that no bias is needed.
If it is added in the future, I would appreciate it. Have a nice day.
Thanks!
from nnom.
Hi jianjia.
I used nnom after I added bias,But I had same issues.
Can you infer any possible reason for this problem to occur?
Before generate_model image
After generate_model image
After using generate_model function, the first layer's weights changes like this. Could this be a problem?
Before
After
Thanks, Have a great weekend!
passingduck
from nnom.
The generate_model()
will destroy the Keras's model, because the quantisation is working on the same instance. So you might copy the model before passing it to generate_model()
or reload it from file.
Hope it helps
from nnom.
Hi @majianjia For support of legacy models, would it be possible to add support for having a no bias in the Conv Layer, or alternatively if their is a hacky way to implement the same, could you please give pointers.
Thanks.
from nnom.
nnom doesn't support bias because the backends must have one to work properly currently.
You must add it somewhere. There are 2 ways to do it.
- modify nnom conv layers, when there isn't bias available, malloc a chunk of memory at the size of output, set it to 0. use it as bias.
- In python code, after loading model (the model after training.). Add a bias tensor to the layer that doesn't have bias. Set it to the correct shape with all values zero.
Hope it helps
from nnom.
Thanks for the pointers.
I tried option 2. However, it resulted in
File "/home/xyz/nnom/scripts/nnom.py", line 216, in find_dec_bits_max_min
int_bits = int(np.ceil(np.log2(max(max_val, min_val))))
OverflowError: cannot convert float infinity to integer
Then just for cleaning the flow , I also introduced a bias_initializer as "random_normal", so that the max_val, min_val don't reduce to 0 for the bias layers. However, then I got the following error :
File "/home/xyz/nnom/scripts/nnom.py", line 731, in quantize_weights
f.write('#define ' + layer.name.upper() + '_BIAS_LSHIFT '+to_cstyle(bias_shift) +'\n\n')
UnboundLocalError: local variable 'bias_shift' referenced before assignment
Trying to figure out the reason for the above.
from nnom.
It appears that nnom uses the name of the layers instead of the instance type. In the case that the layers have a different nomenclature, then the bias_shift variable doesn't get assigned.
from nnom.
Related Issues (20)
- about reshape HOT 3
- 使用了per channel量化和kld量化方法后,出现了多次推理结果不一致的问题
- 关于输出维度的问题 HOT 4
- nnom静态内存支持如何打开? HOT 6
- main_pc.c中的test_x.txt和text_y.txt如何制作?
- 关于识别几秒时长的语音 HOT 3
- inhomogeneous shape after 1 dimensions
- keyword_spotting中的main_pc.c中的test_x.txt和text_y.txt如何制作?
- nothing
- 关于使用DW_Conv2D与Conv2D的移植后使用耗时的问题 HOT 1
- 使用#define NNOM_USING_CMSIS_NN 的错误。 HOT 2
- 运行rnnnoise的example报错 HOT 2
- Error: Deprecated Usage of `np.int` in `to_cstyle` Function in `gen_config.py`
- Keras 3 version compatibility HOT 1
- Installable using pip
- Exception with Tensorflow 2.16 HOT 2
- Consultation on kws examples?
- RNN state makes model output tend towards 0 HOT 2
- kws HOT 1
- RISCV rv32g undefined reference to `__divdi3'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nnom.