美文网首页
tensorflow常见错误记录

tensorflow常见错误记录

作者: 听城 | 来源:发表于2018-10-23 19:30 被阅读43次
    • tensorflow TypeError: run() got multiple values for argument 'feed_dict'
      原因分析:造成此错误的原因为:run()函数接收的fetches参数为一个列表、元组、或者字典,此错误是因为要获取的对象被当作多个参数,正确用法:
           a = tf.constant([10, 20])
           b = tf.constant([1.0, 2.0])
           # 'fetches' can be a singleton
           v = session.run(a)
           # v is the numpy array [10, 20]
           # 'fetches' can be a list.
           v = session.run([a, b])
           # v is a Python list with 2 numpy arrays: the 1-D array [10, 20] and the
           # 1-D array [1.0, 2.0]
           # 'fetches' can be arbitrary lists, tuples, namedtuple, dicts:
           MyData = collections.namedtuple('MyData', ['a', 'b'])
           v = session.run({'k1': MyData(a, b), 'k2': [b, a]})
           # v is a dict with
           # v['k1'] is a MyData namedtuple with 'a' (the numpy array [10, 20]) and
           # 'b' (the numpy array [1.0, 2.0])
           # v['k2'] is a list with the numpy array [1.0, 2.0] and the numpy array
           # [10, 20].
    

    相关文章

      网友评论

          本文标题:tensorflow常见错误记录

          本文链接:https://www.haomeiwen.com/subject/sjzazftx.html