Closed aohan237 closed 5 years ago
hi @aohan237
what is the output_format you are using? tfjs_graph_model does not support some layer types. You can try to convert the keras model to tfjs_layers_model if you haven't.
@kangyizhang
the output_format is model.json, which is the converter generates
just follow the instructions save the entire model
https://www.tensorflow.org/tutorials/keras/save_and_restore_models#save_the_entire_model
You can try to convert the keras model to tfjs_layers_model if you haven't.
how to do this? convert the layer in keras to some stand keras layer, which tfjs have? and then save the model, then convert to js model?
@aohan237
What I mean that when using tensorflowjs_converter pip package to convert your keras model to tfjs format model, there are a list of arguments (https://github.com/tensorflow/tfjs-converter#step-1-converting-a-tensorflow-savedmodel-tensorflow-hub-module-keras-hdf5-or-tfkeras-savedmodel-to-a-web-friendly-format).
You can define input_format and output_format. I think your input_format is keras, and you can set the output format as tfjs_layers_model. You can find more details in the readme.
@kangyizhang
ouput format is not the problem.
python model has some custom layers. which tfjs cant know. so load model will be failed.
i must impl these layers in js and register them, so that tfjs can load the model.
thanks @aohan237 for the update. So it seems like https://github.com/tensorflow/tfjs/issues/1753#issuecomment-512640437 is the root cause. I'll close this issue and use the other one for tracking.
@kangyizhang some updates. tfjs has a few functions lost compared to tfpy, which makes it very difficulty to do this
@aohan237 can you file another issue and list the missing ops?
of course.i will list the missing ops in that issue
I replaced in model.json
BatchNorm
by BatchNormalization
and it seems to work
https://github.com/tensorflow/tfjs/blob/31fd388daab4b21c96b2cb73c098456e88790321/tfjs-layers/src/layers/normalization.ts#L255
i use the converter to transform keras model to js.
but it shows errors as follows:
Unknown layer: BatchNorm. This may be due to one of the following reasons:
what should i do to make this?
how can i make the transformed model work? is there any guide or advice or something else for me to follow? cause the js-doc never says about what to do when error occurs
thanks