将基于Theano的Keras模型定义转换为TensorFlow [英] Converting Theano-based Keras model definition to TensorFlow

查看:73
本文介绍了将基于Theano的Keras模型定义转换为TensorFlow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将基于Theano的Keras模型定义转换为TensorFlow时,更改输入层上input_shape的顺序是否足够?

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

例如,下一层

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

将替换为

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

注意:我不想使用dim_ordering='th'.

推荐答案

Francois Chollet 的答案:

Answer from Francois Chollet:

我认为问题的意思是我应该将什么input_shape传递给我的 假设我正在使用TensorFlow以及我的默认设置 dim_ordering的设置是"tf"".答案是肯定的,这就是您的方法 做到,(img_width, img_height, 3).

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).

请注意,如果要加载已保存的模型, 用Theano和dim_ordering="th"一起训练,得到模型定义 对于带dim_ordering="tf"的TF,您需要转换卷积 内核. Keras为此提供了实用程序.

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.

这篇关于将基于Theano的Keras模型定义转换为TensorFlow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆