Converting Theano-based Keras model definition to TensorFlow

我怕爱的太早我们不能终老 提交于 2019-12-02 21:17:17

问题


When converting Theano-based Keras model definition to TensorFlow, is it enough to change the order of input_shape on the input layer?

For example, the following layer

Convolution2D(32, 3, 3, input_shape=(3, img_width, img_height))

will be replaced as

Convolution2D(32, 3, 3, input_shape=(img_width, img_height, 3))

Note: I don't want to use dim_ordering='th'.


回答1:


Answer from Francois Chollet:

I think the question means "what input_shape should I pass to my first layer given that I'm using TensorFlow and that my default setting for dim_ordering is "tf"". The answer is yep, that's how you do it, (img_width, img_height, 3).

Important to note that if you want to load saved models that were trained with Theano with dim_ordering="th", into a model definition for TF with dim_ordering="tf", you will need to convert the convolution kernels. Keras has utils for that.



来源:https://stackoverflow.com/questions/40730483/converting-theano-based-keras-model-definition-to-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!