Comments (6)
Hi, the input layer should be converted. The converter should find the InputLayer layer and convert that to ncnn Input layer.
Can you attach your keras file and a screenshot of the file opened by Netron.
from keras2ncnn.
Model link: here
Netron Graph: here
from keras2ncnn.
Hi, from the decoded model config string, there is no InputLayer inside your model. Without an input layer, there is no way to know your input shape settings.
However, I am thinking maybe I should add a default input Layer. I will PR that later.
If you want to fix your model. you can edit your model config to:
7767517
12 12
Input input_0 0 1 input_0_blob
Convolution conv2d_3 1 1 input_0_blob conv2d_3_blob 0=16 1=3 2=1 3=1 4=0 5=1 6=432 9=1 11=3 12=1 13=1
Pooling average_pooling2d_3 1 1 conv2d_3_blob average_pooling2d_3_blob 0=1 1=2 11=2 2=2 12=2 3=0 4=0 5=1
Convolution conv2d_4 1 1 average_pooling2d_3_blob conv2d_4_blob 0=32 1=3 2=1 3=1 4=0 5=1 6=4608 9=1 11=3 12=1 13=1
Pooling average_pooling2d_4 1 1 conv2d_4_blob average_pooling2d_4_blob 0=1 1=2 11=2 2=2 12=2 3=0 4=0 5=1
Convolution conv2d_5 1 1 average_pooling2d_4_blob conv2d_5_blob 0=64 1=3 2=1 3=1 4=0 5=1 6=18432 9=1 11=3 12=1 13=1
Pooling average_pooling2d_5 1 1 conv2d_5_blob average_pooling2d_5_blob 0=1 1=2 11=2 2=2 12=2 3=0 4=0 5=1
Reshape flatten_1 1 1 average_pooling2d_5_blob flatten_1_blob 0=-1 1=-233 2=-233 3=1
InnerProduct dense_3 1 1 flatten_1_blob dense_3_blob 0=256 1=1 2=589824 9=1
InnerProduct dense_4 1 1 dense_3_blob dense_4_blob 0=128 1=1 2=32768 9=1
InnerProduct dense_5 1 1 dense_4_blob dense_5_blob 0=2 1=1 2=256 9=1
Softmax dense_5_Softmax 1 1 dense_5_blob dense_5_Softmax_blob 0=0
Here is the decoded config string in your model
{
"class_name": "Sequential",
"config": {
"layers": [
{
"class_name": "Conv2D",
"config": {
"activation": "relu",
"activity_regularizer": null,
"batch_input_shape": [
null,
64,
64,
3
],
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"data_format": "channels_last",
"dilation_rate": [
1,
1
],
"dtype": "float32",
"filters": 16,
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"kernel_size": [
3,
3
],
"name": "conv2d_3",
"padding": "valid",
"strides": [
1,
1
],
"trainable": true,
"use_bias": true
}
},
{
"class_name": "AveragePooling2D",
"config": {
"data_format": "channels_last",
"dtype": "float32",
"name": "average_pooling2d_3",
"padding": "valid",
"pool_size": [
2,
2
],
"strides": [
2,
2
],
"trainable": true
}
},
{
"class_name": "Dropout",
"config": {
"dtype": "float32",
"name": "dropout_5",
"noise_shape": null,
"rate": 0.5,
"seed": null,
"trainable": true
}
},
{
"class_name": "Conv2D",
"config": {
"activation": "relu",
"activity_regularizer": null,
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"data_format": "channels_last",
"dilation_rate": [
1,
1
],
"dtype": "float32",
"filters": 32,
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"kernel_size": [
3,
3
],
"name": "conv2d_4",
"padding": "valid",
"strides": [
1,
1
],
"trainable": true,
"use_bias": true
}
},
{
"class_name": "AveragePooling2D",
"config": {
"data_format": "channels_last",
"dtype": "float32",
"name": "average_pooling2d_4",
"padding": "valid",
"pool_size": [
2,
2
],
"strides": [
2,
2
],
"trainable": true
}
},
{
"class_name": "Dropout",
"config": {
"dtype": "float32",
"name": "dropout_6",
"noise_shape": null,
"rate": 0.5,
"seed": null,
"trainable": true
}
},
{
"class_name": "Conv2D",
"config": {
"activation": "relu",
"activity_regularizer": null,
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"data_format": "channels_last",
"dilation_rate": [
1,
1
],
"dtype": "float32",
"filters": 64,
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"kernel_size": [
3,
3
],
"name": "conv2d_5",
"padding": "valid",
"strides": [
1,
1
],
"trainable": true,
"use_bias": true
}
},
{
"class_name": "AveragePooling2D",
"config": {
"data_format": "channels_last",
"dtype": "float32",
"name": "average_pooling2d_5",
"padding": "valid",
"pool_size": [
2,
2
],
"strides": [
2,
2
],
"trainable": true
}
},
{
"class_name": "Dropout",
"config": {
"dtype": "float32",
"name": "dropout_7",
"noise_shape": null,
"rate": 0.5,
"seed": null,
"trainable": true
}
},
{
"class_name": "Flatten",
"config": {
"data_format": "channels_last",
"dtype": "float32",
"name": "flatten_1",
"trainable": true
}
},
{
"class_name": "Dense",
"config": {
"activation": "relu",
"activity_regularizer": null,
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"dtype": "float32",
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"name": "dense_3",
"trainable": true,
"units": 256,
"use_bias": true
}
},
{
"class_name": "Dropout",
"config": {
"dtype": "float32",
"name": "dropout_8",
"noise_shape": null,
"rate": 0.2,
"seed": null,
"trainable": true
}
},
{
"class_name": "Dense",
"config": {
"activation": "relu",
"activity_regularizer": null,
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"dtype": "float32",
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"name": "dense_4",
"trainable": true,
"units": 128,
"use_bias": true
}
},
{
"class_name": "Dense",
"config": {
"activation": "softmax",
"activity_regularizer": null,
"bias_constraint": null,
"bias_initializer": {
"class_name": "Zeros",
"config": {
"dtype": "float32"
}
},
"bias_regularizer": null,
"dtype": "float32",
"kernel_constraint": null,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {
"dtype": "float32",
"seed": null
}
},
"kernel_regularizer": null,
"name": "dense_5",
"trainable": true,
"units": 2,
"use_bias": true
}
}
],
"name": "sequential_1"
}
}
from keras2ncnn.
Ohh okk Thanks. Since netron showed input layer I thought it's there.
About input size model needs 64×64 . Also adding input in Param file doesn't it affect the number of parameters (first line in .param file)
So maybe correct .Param can be something like this
Input input_0 0 1 input_0_blob 0=1 1=3 2=64 3=64
Right ?
Again Thanks for your help.
from keras2ncnn.
You can check the code, the first line is just a constant magic, but the second line is the layer count and blob count which should be increment. ncnn uses dynamic shapes alone for all executions, so you don't need to give a constant input shape here.
keras2ncnn/keras2ncnn/ncnn_emitter.py
Lines 35 to 84 in 39f2cb9
from keras2ncnn.
Fix in 9841e26, I will close this issue since the issue has been resolved and no other issue raised.
from keras2ncnn.
Related Issues (20)
- "list index out of range" Error for one layer network HOT 2
- fizyr/keras-retinanet2ncnn HOT 2
- Keras Faster R-CNN to NCNN HOT 1
- keras model to ncnn faild,Operator Permute not support HOT 5
- [ERROR] Failed to read h5df file. You are not selecting a valid keras model file. HOT 2
- Decreased accuracy of results HOT 5
- relu6 bug HOT 1
- self.model_config['config'] is a list in model HOT 2
- Keras2ncnn can't support Dense(8, activation = 'tanh', name='predictions') op HOT 1
- Conversion Error: Activation not matched with original h5 HOT 2
- Conversion Error: BianryOp only support two inputs HOT 1
- [ERROR] Failed to load structure descriptor from h5df file. HOT 1
- Mobilenetv3 Keras error HOT 6
- do not support Prelu HOT 1
- Why don't I have ncnn model generation? HOT 4
- IndexError: list index out of range
- print unsupported,Please
- Debug mode error
- Error: numpy alias `float` is deprecated HOT 1
- model conversion error
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 keras2ncnn.