1. 'list' object has no attribute 'lower' 报错如下
Traceback (most recent call last):
  File "H:/FasionAI/MyNet/train.py", line 27, in <module>
    train_logits = model.inference(train_batch, BATCH_SIZE, N_CLASSES)
  File "H:\FasionAI\MyNet\CnnNet.py", line 60, in inference
    pool2 = tf.nn.pool(conv2, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME', name='pooling2')
  File "E:\softinstall\Anaconda\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 931, in pool
    (pooling_type.lower()), [input]) as scope:
AttributeError: 'list' object has no attribute 'lower'

问题原因:是tf.nn.max_pool()而不是tf.nn.pool()

2.tensorflow版本不一致

    1)AttributeError: module 'tensorflow' has no attribute 'scalar_summary'

         tf.image_summary('images', images)改为:tf.summary.image('images', images)

    2)AttributeError: 'module' object has no attribute 'scalar_summary'

        tf.scalar_summary('images', images)改为:tf.summary.scalar('images', images)

     3)AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries'

        tf.merge_all_summaries()改为:summary_op = tf.summary.merge_all()

      4)AttributeError: 'module' object has no attribute 'SummaryWriter'

         tf.train.SummaryWritter改为tf.summary.FileWriter

3.pycharm程序无法识别自己写的程序import时显示红线

    1)打开File--》Setting—》打开 Console下的Python Console,把选项(Add source roots to PYTHONPAT)点击勾选上

    2)右键点击自己的工作空间,找下面的Mark Directory as 选择Source Root,就可以解决上面的问题了

4.ValueError: Both labels and logits must be provided.

  File "H:\FasionAI\MyNet\resnetmodel\resnet_train.py", line 35, in train
    loss_ = loss(logits=logits, labels=labels)
  File "H:\FasionAI\MyNet\resnetmodel\resnet.py", line 148, in loss
    cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=labels,logits=logits)
  File "E:\softinstall\Anaconda\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1935, in sparse_softmax_cross_entropy_with_logits
    labels, logits)
  File "E:\softinstall\Anaconda\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1715, in _ensure_xent_args
    raise ValueError("Both labels and logits must be provided.")
ValueError: Both labels and logits must be provided.

    查看源码后发现是:

  if labels is None or logits is None:
    raise ValueError("Both labels and logits must be provided.")

    也就是说有一个输入为空,后检查发现调用函数 inference_small_config(x, c)时没有return 正确应该是

   return inference_small_config(x, c)  



GitHub 加速计划 / te / tensorflow
28
4
下载
一个面向所有人的开源机器学习框架
最近提交(Master分支:2 个月前 )
4f64a3d5 Instead, check for this case in `ResolveUsers` and `ResolveOperand`, by querying whether the `fused_expression_root` is part of the `HloFusionAdaptor`. This prevents us from stepping into nested fusions. PiperOrigin-RevId: 724311958 2 个月前
aa7e952e Fix a bug in handling negative strides, and add a test case that exposes it. We can have negative strides that are not just -1, e.g. with a combining reshape. PiperOrigin-RevId: 724293790 2 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐