shenweichen / DeepCTR

Easy-to-use,Modular and Extendible package of deep-learning based CTR models .
https://deepctr-doc.readthedocs.io/en/latest/index.html
Apache License 2.0
7.44k stars 2.19k forks source link

How to get multi output for DeepFM? #499

Open jonathonbird opened 1 year ago

jonathonbird commented 1 year ago

I'm trying to use DeepFM to predict scores for the world cup, which has 2 outputs the [left score, right score]. For the y values, the model takes in a (35245, 2) shape, and runs, but only gives one value for the output. Basically I'm asking how to set the amount of nodes in the output layer to 2 instead of 1.

Y_train looks like this:

   home_score  away_score
         0.0         1.0
         1.0         1.0
         0.0         1.0
         1.0         2.0

The model is:

 model = DeepFM(linear_feature_columns,dnn_feature_columns,task='regression')
 model.compile("adam", "mean_squared_error",
               metrics=['mean_squared_error'], )
history = model.fit(train_model_input, Y_train.values,
                    batch_size=256, epochs=10, verbose=2, validation_split=0.2, )
pred_ans = model.predict(test_model_input, batch_size=256)

Using google colab

Anaizii commented 1 year ago

hi,did you slove this problem? I face the same question recently.