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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:41:32  来源:igfitidea点击:

can't import keras.layers.Merge

pythonkeras

提问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.mergedoesn't have a generic public Merge-Layer. Instead you are supposed to import the subclasses like keras.layers.Addor keras.layers.Concatenateetc. directly (or their functional interfaces with the same names lowercase: keras.layers.add, keras.layers.concatenateetc.).

从 keras 2 开始,该模块keras.layers.merge没有通用的公共Merge层。相反,你应该导入像子类keras.layers.Addkeras.layers.Concatenate等直接(或它们具有相同名称的功能接口小写:keras.layers.addkeras.layers.concatenate等)。

See what types of merging layers exist in the keras docs

查看keras 文档中存在哪些类型的合并层