• AttributeError: ‘NoneType‘ object has no attribute ‘get_fetch_list‘


    1. import paddle.fluid as fluid
    2. x1 = fluid.layers.fill_constant(shape=[2,2], value=1, dtype='int64')
    3. x2 = fluid.layers.fill_constant(shape=[2,2], value=1, dtype='int64')
    4. y1 = fluid.layers.sum(x=[x1,x2])
    5. place = fluid.CPUPlace()
    6. exe = fluid.executor.Executor(place)
    7. exe.run(fluid.default_startup_program())
    8. result = exe.run(program=fluid.default_main_program(), fetch_list=[y1])
    9. print(result)
    1. PS C:\Users\timwang> python -u "d:\学习\AI\paddle\constant_sum.py"
    2. C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\paddle\fluid\executor.py:1350: UserWarning: There are no operators in the program to be executed. If you pass Program manually, please use fluid.program_guard to ensure the current Program is being used.
    3. warnings.warn(error_info)
    4. Traceback (most recent call last):
    5. File "d:\学习\AI\paddle\constant_sum.py", line 11, in
    6. exe.run(fluid.default_startup_program())
    7. File "C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\paddle\fluid\executor.py", line 1299, in run
    8. six.reraise(*sys.exc_info())
    9. File "C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\six.py", line 719, in reraise
    10. raise value
    11. File "C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\paddle\fluid\executor.py", line 1285, in run
    12. res = self._run_impl(
    13. File "C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\paddle\fluid\executor.py", line 1510, in _run_impl
    14. return self._run_program(
    15. File "C:\Users\timwang\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\paddle\fluid\executor.py", line 1612, in _run_program
    16. arr = scope.find_var(fetch_var_name).get_fetch_list()
    17. AttributeError: 'NoneType' object has no attribute 'get_fetch_list'

    这个问题是版本问题,转为以下版本就没有问题了

    python:3.7 

    paddle: 2.0.0a0

  • 相关阅读:
    useragent在线查找
    前端项目中资源请求顺序和dom结构顺序不一致,资源启动器有(索引)解析器和脚本
    初探Matrix Android ApkChecker
    排序算法总结-C++实现
    利用SPSS对影响环境的因素分析
    Git命令总结-常用-后续使用频繁的再添加~
    Python---练习:while循环案例:猜数字
    【springcloud】一些项目结构模式
    【云原生&微服务三】SpringCloud之Ribbon是这样实现负载均衡的(源码剖析@LoadBalanced原理)
    【数据结构与算法】链表的实现以及相关算法
  • 原文地址:https://blog.csdn.net/wxhjk/article/details/126721114