如何在python tf.keras.backend.learning_phase(0)中像我们在TensorFlow Java/scala中禁用学习阶段

发布于 2025-02-14 01:23:00 字数 1189 浏览 0 评论 0原文

我正在使用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)
  1. 我需要检查Learning_phase是启用还是禁用?
  2. 如何在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)
  1. I need to check whether learning_phase is enabled or disabled?
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫九 2025-02-21 01:23:00

根据这次对话,这是模型控制的东西。 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文