【发布时间】:2021-09-04 06:09:59
【问题描述】:
我的数据有 channels_first 格式。当我使用 tensorflow 概率层时,出现以下错误:
这是一个示例,其中输入形状为 [1,28,28],可重现代码:Gist(请确保您在 GPU 上运行代码。)
InvalidArgumentError: required broadcastable shapes
[[node gradient_tape/lambda/model_3_mixture_same_family_4_MixtureSameFamily_MixtureSameFamily/log_prob/model_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Independentmodel_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Normal/log_prob/model_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Normal/log_prob/truediv/RealDiv_1 (defined at <ipython-input-22-243a182981d9>:9) ]] [Op:__inference_train_function_7663]
Errors may have originated from an input operation.
Input Source operations connected to node gradient_tape/lambda/model_3_mixture_same_family_4_MixtureSameFamily_MixtureSameFamily/log_prob/model_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Independentmodel_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Normal/log_prob/model_3_mixture_same_family_4_MixtureSameFamily_independent_normal_4_IndependentNormal_Normal/log_prob/truediv/RealDiv_1:
model_3/mixture_same_family_4/MixtureSameFamily/independent_normal_4/IndependentNormal/Softplus (defined at /usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/layers/distribution_layer.py:988)
Function call stack:
train_function
我不确定如何更改源代码以使其适用于通道优先输入形状。有人可以帮我解决这个问题吗?
【问题讨论】:
-
我在尝试重现您的错误时遇到此错误:
InvalidArgumentError: Conv2DCustomBackpropInputOp only supports NHWC. [[node gradient_tape/model_7/sequential_17/conv2d_53/Conv2D/Conv2DBackpropInput (defined at <ipython-input-10-cf6a820743f5>:98) ]] [Op:__inference_train_function_30892] -
@AlexandreMahdhaoui 请确保您可以访问 GPU。 Conv2DCustomBackpropInputOp 仅在设备类型 CPU 上支持 NHWC。
-
我在运行 Gist 时收到了
TypeError: x and y must have the same dtype, got tf.bool != tf.float32。我正在使用 GPU,是否有特定的 TF 版本用于复制?如果你分享一个重现问题的 colab 链接会更容易。 -
@Frightera 我更新了要点。这是 Colab 的链接:colab.research.google.com/drive/…。没有特定的 TF 版本。我的是TF2.6。
-
@DushiFdz 我明天会检查这个,如果它与源代码有关,我会看看它。
标签: python tensorflow tensorflow-probability