gpt4 book ai didi

python - 如何解决 TensorFlow 中的 'BiasGrad requires tensor size <= int32 max' InvalidArgumentError?

转载 作者:行者123 更新时间:2023-12-04 10:31:22 25 4
gpt4 key购买 nike

我正在尝试使用 Keras/Tensorflow 训练卷积神经网络。我的模型编译正确,但是一旦开始训练,就会返回以下错误:

Using TensorFlow backend.

Epoch 1/3

Traceback (most recent call last):
File "./main.py", line 17, in <module>
history = CNN.fit(TrainImages, TrainMasks, epochs = 3)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/keras/engine/training.py", line 1239, in fit
validation_freq=validation_freq)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 196, in fit_loop
outs = fit_function(ins_batch)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/backend.py", line 3727, in __call__
outputs = self._graph_fn(*converted_inputs)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1551, in __call__
return self._call_impl(args, kwargs)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1591, in _call_impl
return self._call_flat(args, self.captured_inputs, cancellation_manager)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1692, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 545, in call
ctx=ctx)

File "/home/tomhalmos/.local/lib/python3.6/site-packages/tensorflow_core/python/eager/execute.py", line 67, in quick_execute
six.raise_from(core._status_to_exception(e.code, message), None)

File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.**InvalidArgumentError: BiasGrad requires tensor size <= int32 max**
[[node gradients/conv2d_22/BiasAdd_grad/BiasAddGrad (defined at /home/tomhalmos/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3009) ]] [Op:__inference_keras_scratch_graph_5496]

Function call stack:
keras_scratch_graph

如果以上内容还不够,我们很乐意提供任何进一步的细节。

最佳答案

边界检查是针对张量中元素的数量。大小限制为 21.47 亿个值 ( int32 )。

将您的图像大小 (h x v) 乘以样本批量大小。将其乘以操作中的 channel 数(例如 Conv2D)。计数大于 2.1e9 的地方是有罪操作。除了减少其中一个数字之外,我看不到任何解决方案。

关于python - 如何解决 TensorFlow 中的 'BiasGrad requires tensor size <= int32 max' InvalidArgumentError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60414562/

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