【发布时间】:2017-10-24 09:51:45
【问题描述】:
我有两个想要使用的包,一个是用 Keras1.2 编写的,另一个是用 tensorflow 编写的。我想使用在 tensorflow 中构建的架构的一部分到 Keras 模型中。
建议使用部分解决方案here,但它适用于顺序模型。关于功能模型的建议 - 将预处理包装在 Lambda 层中 - 不起作用。
以下代码有效:
inp = Input(shape=input_shape)
def ID(x):
return x
lam = Lambda(ID)
flatten = Flatten(name='flatten')
output = flatten(lam(inp))
Model(input=[inp], output=output)
但是,当用预处理的输出张量 flatten(lam(TF_processed_layer)) 替换 flatten(lam(inp)) 时,我得到:“模型的输出张量必须是 Keras 张量。找到:Tensor("Reshape:0", shape=(?, ?), dtype=float32)"
【问题讨论】:
-
你找到答案了吗?
标签: tensorflow keras keras-layer