我想将 mlp_net_input_shaped Shape(?, 32, 32, 1) 馈送到 ConvNN 模型,但它总是得到 Shape(1, 32, 32, 1),所以这是错误的。Shape(32, 32) 来自 matmul 函数,这里是代码
# Define input placeholders for user, item and label.
user = tf.placeholder(tf.int32, shape=(None, 1))
item = tf.placeholder(tf.int32, shape=(None, 1))
label = tf.placeholder(tf.int32, shape=(None, 1))
# User embedding for MLP
mlp_u_var = tf.Variable(tf.random_normal([len(users), 32], stddev=0.05), name='mlp_user_embedding')
mlp_user_embedding = tf.nn.embedding_lookup(mlp_u_var, user)
# Item embedding for MLP
mlp_i_var = tf.Variable(tf.random_normal([len(items), 32], stddev=0.05), name='mlp_item_embedding')
mlp_item_embedding = tf.nn.embedding_lookup(mlp_i_var, item)
# Our MLP layers
mlp_user_embed = tf.keras.layers.Flatten()(mlp_user_embedding)
mlp_item_embed = tf.keras.layers.Flatten()(mlp_item_embedding)
#mlp_concat = tf.keras.layers.concatenate([mlp_user_embed, mlp_item_embed])
#Outer Product
mlp_relation = tf.matmul(tf.transpose(mlp_user_embed), mlp_item_embed)
mlp_net_input = tf.expand_dims(mlp_relation, -1)
ml_net_input_shaped = tf.reshape(mlp_relation, [-1, 32, 32, 1])