gpt4 book ai didi

python - 在 Keras 中使用 colocate_with

转载 作者:太空宇宙 更新时间:2023-11-03 15:35:13 25 4
gpt4 key购买 nike

colocate_with 在 Keras 中还有其他用途吗?此处记录的 Keras 模型 API 代码:https://keras.io/models/model/在这里:https://www.tensorflow.org/api_docs/python/tf/keras/models/Model导致弃用警告。引用的代码不直接使用 colocate_with(尽管 API 可能使用 colocate_with)。此模型 API 是否会被弃用或警告是否有误?

Keras 文档中的示例代码:

from keras.models import Model
from keras.layers import Input, Dense

a = Input(shape=(32,))
b = Dense(32)(a)
model = Model(inputs=a, outputs=b)

来自 TensorFlow 文档的示例代码:

import tensorflow as tf

inputs = tf.keras.Input(shape=(3,))
x = tf.keras.layers.Dense(4, activation=tf.nn.relu)(inputs)
outputs = tf.keras.layers.Dense(5, activation=tf.nn.softmax)(x)
model = tf.keras.Model(inputs=inputs, outputs=outputs)

这两个示例都会导致弃用警告:

...deprecation.py:323] From ~/.local/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.

此警告和 colocate_with 的使用似乎与“What is colocate_with used for in tensorflow?”中引用的不同

是否会弃用已记录的使用模型 API 的方法?除了使用顺序模型,还有其他替代方法吗?

最佳答案

目前的master分支还没有清理掉废弃的代码。 nightly 已经修复了相当多的此类警告,并将在下一个版本中生效。

详情请看这里: https://github.com/tensorflow/tensorflow/issues/25996

关于python - 在 Keras 中使用 colocate_with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55203017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com