for value in summary.value: AttributeError: numpy.bool_ object has no attribute value

解决方式1:然而对我这个问题没有效果

  def add_summary(self, summary, global_step=None):
    """Adds a `Summary` protocol buffer to the event file.

    This method wraps the provided summary in an `Event` protocol buffer
    and adds it to the event file.

    You can pass the result of evaluating any summary op, using
    `tf.Session.run` or
    `tf.Tensor.eval`, to this
    function. Alternatively, you can pass a `tf.compat.v1.Summary` protocol
    buffer that you populate with your own data. The latter is
    commonly done to report evaluation results in event files.

    Args:
      summary: A `Summary` protocol buffer, optionally serialized as a string.
      global_step: Number. Optional global step value to record with the
        summary.
    """
    if isinstance(summary, bytes):
      summ = summary_pb2.Summary()
      summ.ParseFromString(summary)
      summary = summ

    # We strip metadata from values with tags that we have seen before in order
    # to save space - we just store the metadata on the first value with a
    # specific tag.
    for value in summary.value:
      if not value.metadata:
        continue

      if value.tag in self._seen_summary_tags:
        # This tag has been encountered before. Strip the metadata.
        value.ClearField("metadata")
        continue

      # We encounter a value with a tag we have not encountered previously. And
      # it has metadata. Remember to strip metadata from future values with this
      # tag string.
      self._seen_summary_tags.add(value.tag)

    event = event_pb2.Event(summary=summary)
    self._add_event(event, global_step)

向事件文件添加一个Summary协议缓冲区。
此方法将提供的Summary包装在“事件”协议缓冲区中,并将其添加到事件文件中。
您可以使用tf.Session.runtf.Tensor.eval将评估任何摘要操作的结果传递给此函数。
或者,您可以传递使用自己的数据填充的 tf.compat.v1.Summary 协议缓冲区。后者通常用于在事件文件中报告评估结果。
参数:
SummarySummary协议缓冲区,可选择序列化为字符串。
global_step:数字。 与Summary一起记录的可选全局步长值。

添加链接描述

解决方式:
没有真正意义上解决,不过确实解决了问题,因为修改前代码对应tensorflow版本低,不知道如何进行修改,添加一个语句就解决了。
在这里插入图片描述

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值