发生异常:ImportError无法导入名称“重新缩放”

2024-04-28 12:18:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图训练深度学习模型,但在以下方面存在以下错误:

 from tensorflow.keras.layers.experimental.preprocessing import Rescaling
Exception has occurred: ImportError
cannot import name 'Rescaling'

我正在使用这些版本-

python 3.6.10 on Miniconda3
tensorflow-gpu=2.1.0
keras-gpu=2.2.4
cuda 11 
cuDNN=8.0.1

关于这个问题的帮助将不胜感激


Tags: from模型importgpulayerstensorflow错误exception
1条回答
网友
1楼 · 发布于 2024-04-28 12:18:06

不熟悉tensorflow,但是,tensorflow表示GPU是一个单独的包

https://www.tensorflow.org/install/gpu 对于1.15及更高版本,CPU和GPU包是分开的。您正在使用的版本看起来较新

pip install tensorflow  # stable
pip install tf-nightly  # preview

在您的情况下,requirements.txt将被更新为在其中包含tensorflow,而不是tensorflow gpu

我将从他们的例子开始: https://www.tensorflow.org/api_docs/python/tf/keras/layers/experimental/preprocessing/Rescaling

import tensorflow as tf
tf.keras.layers.experimental.preprocessing.Rescaling(
    scale, offset=0.0, name=None, **kwargs
)

相关问题 更多 >