Input shape of wide and deep model

Hello mentor, in lab 1 of week 4, a wide and deep model is defined as

# inherit from the Model base class
class WideAndDeepModel(Model):
    def __init__(self, units=30, activation='relu', **kwargs):
        '''initializes the instance attributes'''
        super().__init__(**kwargs)
        self.hidden1 = Dense(units, activation=activation)
        self.hidden2 = Dense(units, activation=activation)
        self.main_output = Dense(1)
        self.aux_output = Dense(1)

    def call(self, inputs):
        '''defines the network architecture'''
        input_A, input_B = inputs
        hidden1 = self.hidden1(input_B)
        hidden2 = self.hidden2(hidden1)
        concat = concatenate([input_A, hidden2])
        main_output = self.main_output(concat)
        aux_output = self.aux_output(hidden2)
        
        return main_output, aux_output

I then tried to use the model.summary() to show its layer, while it got an error on the input shape as:


Would you explain why the dim of the shape must be 4 ? Thanks.

In here:

define inputs

input_a = Input(shape=[1], name=“Wide_Input”)

What is the shape[1] size?

Hello mentor, I am a bit confused. The define inputs part is for the sequential API, rather than the sub-classing model which I am asking about

Hmm, If I comment the shape with 4 dimensions and run that cell again, I get a valid model;

if I dont comment it out there is a shape conflict:

perhaps restarting the kernel would help for your case.

1 Like

Hello mentor, thank you so much for your answer !

1 Like