Я пытаюсь реализовать модель 3Dcnn в керасе, но у меня проблема с тем, как называется моя модель. Запустив следующий код:
...
...
...
input_layer = Input((16, 16, 16, 3))
x = inception_v4_stem(input_layer)
for i in range(num_A_blocks):
x = inception_v4_A(x)
x = inception_v4_reduction_A(x)
for i in range(num_B_blocks):
x = inception_v4_B(x)
x = inception_v4_reduction_B(x)
for i in range(num_C_blocks):
x = inception_v4_C(x)
x = AveragePooling3D((4, 4, 4), strides=(1, 1, 1), padding="same", data_format="channels_last")
x = Dropout(0.5)
x = Flatten()
x = Dense(nb_classes, activation='softmax')
## define the model with input layer and output layer
model = Model(inputs = input_layer, outputs = x)
model.summary()
model.compile(loss=categorical_crossentropy, optimizer=Adadelta(lr=0.1), metrics=['acc'])
model.fit(x=xtrain, y=y_train, batch_size=128, epochs=50, validation_split=0.2)
Я получаю следующую ошибку:
Traceback (most recent call last):
File "kI3DV2y.py", line 275, in <module>
model = Model(inputs = [input_layer], outputs = x)
File "C:\Users\sancy\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Users\sancy\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\network.py", line 94, in __init__
self._init_graph_network(*args, **kwargs)
File "C:\Users\sancy\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\network.py", line 198, in _init_graph_network
'Found: ' + str(x))
ValueError: Output tensors to a Model must be the output of a Keras `Layer` (thus holding past layer metadata). Found: <keras.layers.core.Dense object at 0x000001EDAEC47348>
Может кто-нибудь сказать мне, что я здесь не так делаю и как правильно определить свою модель? Спасибо в ожидании.
Window 10
Python 3.7.6
Tensorflow-gpu==1.14
Keras==2.3.1
Wrote the code based on keras 2 API