当我尝试将模型用作图层时,我在Keras中遇到异常。我的代码如下:
from keras import layers
from keras import applications
from keras import Input
from keras.models import Model
xception_base = applications.Xception(weights=None,
include_top=False)
left_input = Input(shape=(250, 250, 3))
right_input = Input(shape=(250, 250, 3))
left_features = xception_base(left_input)
right_input = xception_base(right_input)
merged_features = layers.concatenate([left_features, right_input], axis=-1)
model = Model([left_input, right_input], merged_features)
这是我得到的例外。从异常中我不清楚是怎么回事
Traceback (most recent call last):
File "/home/asattar/workspace/projects/keras-examples/chapter7/MergeTwoModels.py", line 18, in <module>
model = Model([left_input, right_input], merged_features)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.2.4-py2.7.egg/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.2.4-py2.7.egg/keras/engine/network.py", line 93, in __init__
self._init_graph_network(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Keras-2.2.4-py2.7.egg/keras/engine/network.py", line 224, in _init_graph_network
assert node_index == 0
AssertionError
有人可以帮助我解决可能出现的问题吗?
当我这样做时也没有错误
model = Model(left_input, left_features)
答案 0 :(得分:0)
实际上是nvm。我意识到我弄乱了变量名
Confusion Matrix
[[12357 2936 6039]
[ 1479 4301 1927]
[ 3316 1924 12495]]
Classification Report
precision recall f1-score support
class -1 0.72 0.58 0.64 21332
class 0 0.47 0.56 0.51 7707
class 1 0.61 0.70 0.65 17735
avg / total 0.64 0.62 0.62 46774
使图形变为圆形。