-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to load saved SDM weights properly to reproduce embeddings? #29
Comments
refer to examples/run_sdm.py |
@wangzhegeek Thanks for your quick reply. My case is I trained the model in one notebook to get the user embeddings and item embeddings. Then I loaded the model in another notebook and got the same item embeddings but completely different user embeddings. I assume the reason is that some hidden states of RNN layer is lost based on my reading from this thread |
我先train好了model,save下来: import tensorflow as tf if tf.version >= '2.0.0': model = SDM(user_feature_columns, optimizer = optimizers.Adam(lr=0.001, clipnorm=5.0) model.compile(optimizer=optimizer, loss=sampledsoftmaxloss) # "binary_crossentropy") history = model.fit(train_model_input, K.set_learning_phase(False) model.save('/tmp/saved_model.h5') 然后再加载模型: 然后用加载的模型获取embedding: user_embedding_model = Model(inputs=loaded_model.user_input, outputs=loaded_model.user_embedding) user_embs = user_embedding_model.predict(test_user_model_input, batch_size=2 ** 12) print(user_embs.shape) 出现Attribute Error: AttributeError: 'Model' object has no attribute 'user_input' |
同样的问题 不知道有没有解决? |
采用save_weights和load_weights方式也出现该问题 |
请问这个问题你自己有什么解决方案吗? |
这个问题现在都有,至今未解决 |
Describe the question(问题描述)
After I saved SDM weights and loaded it in another process. It produced different user embeddings.
How to save SDM model properly and then load it properly to reproduce embeddings?
Operating environment(运行环境):
The text was updated successfully, but these errors were encountered: