recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

How to correctly interpret the prediction output of a model with DCN layer?

Open jamie613 opened this issue 2 years ago • 0 comments

Why is the prediction of the model, which contains a DCN layer, returns two values?

The model and brief codes are as followed:

def cross_model(n_users, n_items):
  user_in = (Input layer)
  item_in = (Input layer)

  user_emb = (user embedding layers)
  item_emb = (item embedding layers)

  features = tf.concat([user_emb, item_emb], axis=1)

  cross = tfrs.layers.dnc.Cross()(features)

  y = layers.Dense(1)(cross)

  model = models.Model (inputs=[user_in, item_in], outputs = y)
  model.compile(optimizer='AdaGrad', 
                           loss=tf.keras.losses.MeanSquaredError(), 
                           metrics=[tf.keras.metrics.RootMeanSquaredError()])

  return model

model = cross_model()
model.fit(x=[train['userID'], train['itemID']],  y=train['rating'])

## prediction
model({'user_in' : np.array([test_userID]), 'item_in' : np.array([test_itemID])})

The prediction returns an EagerTensor of shape [1, 2, 1]. The first value of the prediction seems to connect with the userID and the second with the itemID. Each userID and itemID have their distinct values, and the values won't change, regardless the combination of userID and itemID.

If I remove the DCN layer, model.predict or model({}) returns only one value.

Why? Or, what did I do wrong?

jamie613 avatar Feb 07 '23 13:02 jamie613