Python 无法导入 keras.layers.Merge
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51031519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can't import keras.layers.Merge
提问by boltzsman
I want to merge two LSTM models in Keras. I have seen many examples of importing Merge as:
我想在 Keras 中合并两个 LSTM 模型。我见过很多导入 Merge 的例子:
from keras.layers import Merge
When I do this, I get an import error.
执行此操作时,出现导入错误。
ImportError: cannot import name 'Merge'.
ImportError: cannot import name 'Merge'.
Has there been some refactor and now Merge is elsewhere?
是否进行了一些重构,现在 Merge 在别处?
回答by ascripter
As of keras 2, the module keras.layers.merge
doesn't have a generic public Merge
-Layer. Instead you are supposed to import the subclasses like keras.layers.Add
or keras.layers.Concatenate
etc. directly (or their functional interfaces with the same names lowercase: keras.layers.add
, keras.layers.concatenate
etc.).
从 keras 2 开始,该模块keras.layers.merge
没有通用的公共Merge
层。相反,你应该导入像子类keras.layers.Add
或keras.layers.Concatenate
等直接(或它们具有相同名称的功能接口小写:keras.layers.add
,keras.layers.concatenate
等)。
See what types of merging layers exist in the keras docs
查看keras 文档中存在哪些类型的合并层