gpt4 book ai didi

`AssertionError` 方法上的 TensorFlow `fit()`

转载 作者:行者123 更新时间:2023-12-02 07:28:59 27 4
gpt4 key购买 nike

tf.Dataset 传递到 tf.Keras 模型的 fit() 时,我收到 AssertionError方法。

我正在使用tensorflow==2.0.0

我检查了我的数据集是否有效:

# for x,y in dataset:
# print(x.shape, y.shape)

这会产生模型输入数据的正确形状。

完整的跟踪是:

Traceback (most recent call last):
File "/anaconda3/envs/ml36/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/anaconda3/envs/ml36/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/me/train.py", line 102, in <module>
start_training(**arguments)
File "/me/train.py", line 66, in start_training
steps_per_epoch=TRAIN_STEPS_PER_EPOCH,
File "/anaconda3/envs/ml36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 728, in fit
use_multiprocessing=use_multiprocessing)
File "/anaconda3/envs/ml36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_distributed.py", line 789, in fit
*args, **kwargs)
File "/anaconda3/envs/ml36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_distributed.py", line 776, in wrapper
mode=dc.CoordinatorMode.INDEPENDENT_WORKER)
File "/anaconda3/envs/ml36/lib/python3.6/site-packages/tensorflow_core/python/distribute/distribute_coordinator.py", line 782, in run_distribute_coordinator
rpc_layer)
File "/anaconda3/envs/ml36/lib/python3.6/site-packages/tensorflow_core/python/distribute/distribute_coordinator.py", line 344, in _run_single_worker
assert strategy
AssertionError

最佳答案

在tensorflow 2.0.0的最终版本上运行gcloud ai-platform local train时,我遇到了同样的错误。然而,它正在开发早期版本。尝试降级到2.0.0b1:

pip install tensorflow==2.0.0b1

--

还发现,如果直接在 python 中运行或者在云端运行,则不会出现此错误。

关于 `AssertionError` 方法上的 TensorFlow `fit()`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58868459/

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