我想把create_model函数重写成Keras Functional API。但是,在TPU上运行它时,当我翻译它时,我发现在create_method函数中使用占位符时出现错误。在最初的示例中,作者没有将显式占位符放入create_method函数。我使用Keras输入函数,因为我需要实例化一个Keras张量来开始,显然这是一个占位符。有没有办法去掉create_method函数中的占位符?
下面是我的代码片段:
def create_model(data_format):
if data_format == 'channels_first':
input_shape = [1, 28, 28]
else:
assert data_format == 'channels_last'
input_shape = [28, 28, 1]
l = tf.keras.layers
m = tf.keras.models
b = tf.keras.backend
v = tf.contrib.layers
# The model consists of a sequential chain of layers, so tf.keras.Sequential
# (a subclass of tf.keras.Model) makes for a compact description.
input = l.Input(shape=(28, 28, 1))
visible = l.Reshape(target_shape=input_shape, input_shape=(28*28,))(input)当我从the provided MNIST TPU Code创建它时,我得到以下错误
进纸器外部的
占位符
但是我也不能像在Sequential Code中那样在没有占位符的情况下运行它,或者有办法做到这一点吗?
https://stackoverflow.com/questions/51926624
复制相似问题