2
$\begingroup$

Model :

model = vgg16(weights = 'imagenet', include_top=False)
cl1 = Dense(2, activation = 'softmax',name='class_1')(x)
cl2 = Dense(2, activation = 'softmax',name='class_2')(x)
model = Model(inputs=model.input, outputs= [cl1,cl2])

loss = ['categorical_crossentropy','categorical_crossentropy']
model.compile(optimizer=opt, loss=loss  , metrics=['categorical_accuracy'])

data_input_pipeline :

  train_generator=train_datagen.flow_from_dataframe()

  def custom_generator(generator):
    for img_batch, lb_batch in generator:
        img_batch_list = tf.data.Dataset.from_tensor_slices(img_batch)
        for img,img_lb in zip(img_batch,lb_batch):
              ** some code block to change img_lb into tuple , value of the key in tuple is in 
               Tf.tensor shape(1,2)  **
              ** eg : updated_label_tuple ={class1:[1,0],class2: [0,1]}  **

        

        yield (updated_image_batch_tensor, updated_label_batch_list)

  train_ds = 
  val_ds= 

  model.fit(train_ds,
                    steps_per_epoch=200 ,
                    validation_data=val_ds,
                    validation_steps=40,
                    epochs=50,verbose=1)

Error :

check_types=check_types) File "/home/samjith/anaconda3/envs/tf2/lib/python3.6/site-packages/tensorflow_core/python/data/util/nest.py", line 299, in assert_shallow_structure "Input has type: %s." % type(input_tree)) TypeError: If shallow structure is a sequence, input must also be a sequence. Input has type: <class 'list'>.

Here i have to feed the data into 2 seperate dense layers which will perform 2 different tasks. I passed it as a tuple like mentioned here, but i got the above error ..

Is this right way to feed the data into two dense(2) layers ? How to solve this bug !!

$\endgroup$