刚开始用paddle就遇到如下的两个问题
代码:
import paddle.fluid as fluid
x1 = fluid.layers.fill_constant(shape=[2, 2], value=1, dtype='int64')
x2 = fluid.layers.fill_constant(shape=[2, 2], value=1, dtype='int64')
y1 = fluid.layers.sum(x=[x1, x2])
place = fluid.CPUPlace()
exe = fluid.executor.Executor(place)
exe.run(fluid.default_startup_program())
报错如下:
Traceback (most recent call last):
File "D:/WorkFiles/Python/test/debug.py", line 11, in <module>
exe.run(fluid.default_startup_program())
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1110, in run
six.reraise(*sys.exc_info())
File "D:\WorkTools\Anaconda\lib\site-packages\six.py", line 703, in reraise
raise value
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1098, in run
return self._run_impl(
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1230, in _run_impl
return self._run_program(
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1332, in _run_program
arr = scope.find_var(fetch_var_name).get_fetch_list()
AttributeError: 'NoneType' object has no attribute 'get_fetch_list'
代码:
import paddle.fluid as fluid
import numpy as np
a = fluid.layers.create_tensor(dtype='int64', name='a')
b = fluid.layers.create_tensor(dtype='int64', name='b')
y = fluid.layers.sum(x=[a, b])
报错如下:
Traceback (most recent call last):
File "D:/WorkFiles/Python/test/debug.py", line 6, in <module>
y = fluid.layers.sum(x=[a, b])
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\layers\nn.py", line 10845, in sum
return paddle.add_n(x)
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\tensor\math.py", line 849, in add_n
return core.ops.sum(inputs, 'use_mkldnn', False)
ValueError: (InvalidArgument) Sum operator should have at least one tensor
[Hint: Expected dtype != -1, but received dtype:-1 == -1:-1.] (at D:\v2.0.1\paddle\paddle\fluid\operators\sum_op.cc:146)
[operator < sum > error]
怎么解决啊大佬们
代码:
import paddle.fluid as fluid
x1 = fluid.layers.fill_constant(shape=[2, 2], value=1, dtype='int64')
x2 = fluid.layers.fill_constant(shape=[2, 2], value=1, dtype='int64')
y1 = fluid.layers.sum(x=[x1, x2])
place = fluid.CPUPlace()
exe = fluid.executor.Executor(place)
exe.run(fluid.default_startup_program())
报错如下:
Traceback (most recent call last):
File "D:/WorkFiles/Python/test/debug.py", line 11, in <module>
exe.run(fluid.default_startup_program())
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1110, in run
six.reraise(*sys.exc_info())
File "D:\WorkTools\Anaconda\lib\site-packages\six.py", line 703, in reraise
raise value
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1098, in run
return self._run_impl(
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1230, in _run_impl
return self._run_program(
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\executor.py", line 1332, in _run_program
arr = scope.find_var(fetch_var_name).get_fetch_list()
AttributeError: 'NoneType' object has no attribute 'get_fetch_list'
代码:
import paddle.fluid as fluid
import numpy as np
a = fluid.layers.create_tensor(dtype='int64', name='a')
b = fluid.layers.create_tensor(dtype='int64', name='b')
y = fluid.layers.sum(x=[a, b])
报错如下:
Traceback (most recent call last):
File "D:/WorkFiles/Python/test/debug.py", line 6, in <module>
y = fluid.layers.sum(x=[a, b])
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\fluid\layers\nn.py", line 10845, in sum
return paddle.add_n(x)
File "D:\WorkTools\Anaconda\lib\site-packages\paddle\tensor\math.py", line 849, in add_n
return core.ops.sum(inputs, 'use_mkldnn', False)
ValueError: (InvalidArgument) Sum operator should have at least one tensor
[Hint: Expected dtype != -1, but received dtype:-1 == -1:-1.] (at D:\v2.0.1\paddle\paddle\fluid\operators\sum_op.cc:146)
[operator < sum > error]
怎么解决啊大佬们