【问题标题】:Issue with using tf.contrib.layers.group_norm with variable batch size使用具有可变批量大小的 tf.contrib.layers.group_norm 时出现问题
【发布时间】:2019-02-02 12:51:41
【问题描述】:

我正在尝试将组规范用作我的 CNN 的一部分。但是我收到以下错误,我认为这与输入图像的占位符的第一个维度(即批量大小)设置为无有关。组规范实现涉及一个不能很好地处理这个的重塑操作。您能否为此提出一个解决方法?

TypeError:无法将类型对象转换为张量。内容:[无、16、64、64、12、2]。考虑将元素转换为支持的类型。

感谢您的时间和精力。

【问题讨论】:

    标签: python tensorflow conv-neural-network normalization


    【解决方案1】:

    我相信这是 Tensorflow 上的一个已知问题,您可以在此处阅读更多信息:https://github.com/tensorflow/tensorflow/issues/24409

    简而言之,这个错误是由normalization.py#L303引起的,可以通过在 normalization.py 的第 252 行之后添加以下两行来修复:

    original_shape = [-1 if s.value is None else s for s in original_shape]
    if len([s for s in original_shape if s == -1]) > 1:
        raise ValueError('Only one axis dimension can be undefined in the input tensor')
    

    以及第 302 行之后的以下行:

    inputs_shape = [-1 if s is None else s for s in inputs_shape]
    

    来源:This tensorflow github 页面上的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-06
      • 1970-01-01
      • 2021-03-12
      • 2016-12-24
      • 2011-03-25
      • 1970-01-01
      • 2020-02-26
      • 2017-12-22
      相关资源
      最近更新 更多