【发布时间】:2021-08-30 09:18:15
【问题描述】:
在我的代码中,我收到了这个错误。我该如何解决?
ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, None, None, 3), dtype=tf.float32, name='input_2'), name='input_2', description="created by layer 'input_2'") at layer "conv1_pad". The following previous layers were accessed without issue: []
我的模特是
def multiple_outputs(generator):
for batch_x,batch_y in generator:
yield (batch_x, np.hsplit(batch_y,[26,28])) #here splitting input data into 6 groups
image_input = Input(shape=(input_size))
base_model =ResNet50(weights='imagenet',include_top=False)
m = base_model.output
x = GlobalAveragePooling2D(name='avg_pool')(m)
x = Dropout(0.2)(x)
type_out = Dense(26, activation='sigmoid', name='type_output')(x)
top_out = Dense(3, activation='softmax', name='top_output')(x)
model = Model(inputs=image_input,outputs= [type_out, top_out])
下面我提到了model.fit部分
history = model.fit(x=multiple_outputs(train_generator),
steps_per_epoch=STEP_SIZE_TRAIN,
validation_data=multiple_outputs(valid_generator),
validation_steps=STEP_SIZE_VALID,
callbacks=callbacks,
max_queue_size=10,
workers=1,
use_multiprocessing=False,
epochs=1)
请问有人可以帮我解决这个问题吗?
【问题讨论】:
标签: tensorflow keras graph tf.keras image-classification