Giter Site home page Giter Site logo

运行example文件夹下的代码,想把模型保存为save model格式,同样方式dssm模型成功保存,youtubematch、sdm、mind却保存报错 about deepmatch HOT 9 OPEN

shenweichen avatar shenweichen commented on May 26, 2024
运行example文件夹下的代码,想把模型保存为save model格式,同样方式dssm模型成功保存,youtubematch、sdm、mind却保存报错

from deepmatch.

Comments (9)

chenkejin avatar chenkejin commented on May 26, 2024 8

这个问题主要是因为core文件中不能用list 方式创建layer,你将其改为字典,而且字典的key必须为字符串
修改deepctr/layers/core.py
self.activation_layers={}
for i in range(len(self.hidden_units)):
self.activation_layers[str(i)]=activation_layer(self.activation)
# self.activation_layers = [activation_layer(self.activation) for _ in range(len(self.hidden_units))]
# print("activation num:", len(self.activation_layers))
if self.output_activation:
# self.activation_layers[-1] = activation_layer(self.output_activation)
self.activation_layers[str(len(self.hidden_units)-1)] = activation_layer(self.output_activation)

from deepmatch.

guixianjin avatar guixianjin commented on May 26, 2024 6

这个问题主要是因为core文件中不能用list 方式创建layer,你将其改为字典,而且字典的key必须为字符串 修改deepctr/layers/core.py self.activation_layers={} for i in range(len(self.hidden_units)): self.activation_layers[str(i)]=activation_layer(self.activation) # self.activation_layers = [activation_layer(self.activation) for _ in range(len(self.hidden_units))] # print("activation num:", len(self.activation_layers)) if self.output_activation: # self.activation_layers[-1] = activation_layer(self.output_activation) self.activation_layers[str(len(self.hidden_units)-1)] = activation_layer(self.output_activation)

确实有效。
补充一下,再改一下 deepctr/layers/core.py 文件中:

                # fc = self.activation_layers[i](fc, training=training)
                fc = self.activation_layers[str(i)](fc, training=training)
                # fc = self.activation_layers[i](fc)
                fc = self.activation_layers[str(i)](fc)

然后用 tf.saved_model.save() 即可保存 pb 格式文件。

from deepmatch.

marzooq-unbxd avatar marzooq-unbxd commented on May 26, 2024 1

Was this solved for everyone?
I still cant fix this for sdm, is the change only required in deepctr?
Could this have any impact (DynamicMultiRNN in DeepMatch)

cell_list.append(single_cell_residual)

from deepmatch.

shuDaoNan9 avatar shuDaoNan9 commented on May 26, 2024

这都被你发现了,你是一个个都试过存pb格式了么?看样子用类似Java调模型的不多,都走TensorFlow serving实时推荐的去了吧

from deepmatch.

shuDaoNan9 avatar shuDaoNan9 commented on May 26, 2024

还是自己动手改造到TF2版本后,再直接存为savemodel吧。马上过年了,正好有时间弄了

from deepmatch.

Outstandingwinner avatar Outstandingwinner commented on May 26, 2024

这都被你发现了,你是一个个都试过存pb格式了么?看样子用类似Java调模型的不多,都走TensorFlow serving实时推荐的去了吧

不管是Java调模型还是用tensorflow-serving都需要调用pb文件

from deepmatch.

Outstandingwinner avatar Outstandingwinner commented on May 26, 2024

还是自己动手改造到TF2版本后,再直接存为savemodel吧。马上过年了,正好有时间弄了

这个代码本来就是TF2可以成功运行的。

from deepmatch.

shuDaoNan9 avatar shuDaoNan9 commented on May 26, 2024

这都被你发现了,你是一个个都试过存pb格式了么?看样子用类似Java调模型的不多,都走TensorFlow serving实时推荐的去了吧

不管是Java调模型还是用tensorflow-serving都需要调用pb文件

在训练完后单独保存embeding后的特征向量,然后自己在其它程序里面算物品和用户向量的得分取topn也是能算的,此时甚至不需要保存模型本身。

from deepmatch.

shuDaoNan9 avatar shuDaoNan9 commented on May 26, 2024

还是自己动手改造到TF2版本后,再直接存为savemodel吧。马上过年了,正好有时间弄了

这个代码本来就是TF2可以成功运行的。

这个不是纯TF2,兼容TF1/2还是有差别的

from deepmatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.