Issue
In my code I am getting this error. How I can solve it?
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: []
My model is
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])
following I have mentioned model.fit
section
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)
Please, can someone help me in solving this issue?
Solution
Answer is, here I have done a mistake in model initialization. Input_tensor should be added in model initialization.
base_model = ResNet50(weights='imagenet', include_top=False, input_tensor=image_input)
Answered By - EverythingNeedToBeKnown
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.