如何在python tf.keras.backend.learning_phase(0)中像我们在TensorFlow Java/scala中禁用学习阶段
我正在使用LSTM模型并在下面加载保存的模型
val modelFiles: List[String] = List(
"saved_model.pb",
"keras_metadata.pb",
"variables/variables.data-00000-of-00001",
"variables/variables.index"
)
val modelDir = "/Models/lstm_model_fullname_with_watchlist"
val tempDirectory = Files.createTempDirectory("lstm").toFile
val savedModel = SavedModelBundle.load(tempDirectory.getAbsolutePath, "serve")
new LSTMModel(
session = savedModel.session()
)
并将预测调用如下所示,
val input1: Tensor[_] = Tensor.create(embed(name1))
val input2: Tensor[_] = Tensor.create(embed(name2))
val result: Tensor[_] = session.runner()
.fetch("StatefulPartitionedCall:0")
.feed("serving_default_input_1:0", input1)
.feed("serving_default_input_2:0", input2)
.run().get(0)
- 我需要检查Learning_phase是启用还是禁用?
- 如何在Scala或Java中禁用学习阶段。我正在使用Scala。但是Java参考也很好,我希望两者都会相似。
我遇到了这个 link anyChance by anyChance此选项本身不可用吗?
我当前的TensorFlow版本是1.15.0。
提前致谢 ....
I am using lstm model and loading the saved model as below
val modelFiles: List[String] = List(
"saved_model.pb",
"keras_metadata.pb",
"variables/variables.data-00000-of-00001",
"variables/variables.index"
)
val modelDir = "/Models/lstm_model_fullname_with_watchlist"
val tempDirectory = Files.createTempDirectory("lstm").toFile
val savedModel = SavedModelBundle.load(tempDirectory.getAbsolutePath, "serve")
new LSTMModel(
session = savedModel.session()
)
and calling the prediction as below
val input1: Tensor[_] = Tensor.create(embed(name1))
val input2: Tensor[_] = Tensor.create(embed(name2))
val result: Tensor[_] = session.runner()
.fetch("StatefulPartitionedCall:0")
.feed("serving_default_input_1:0", input1)
.feed("serving_default_input_2:0", input2)
.run().get(0)
- I need to check whether learning_phase is enabled or disabled?
- How to disable learning phase in Scala or Java. I am using scala. but Java reference is also fine, I hope both would be similar.
I came across this link by anychance this option itself not available ?
my current version of tensorflow is 1.15.0.
Thanks in advance ....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这次对话,这是模型控制的东西。 https://github.com/tensorflow/java/java/java/issues/465
As per this conversation this is something controlled by the model. https://github.com/tensorflow/java/issues/465