训练时向网络feed图像、标签、一维向量时出错
Created by: zhijl
参考了fluid/icnet中的样例代码改写的:
这里的图像shape为 [3, 256, 256],label 的shape为 [1],另一个 label 的 shape 为 [58]
...
images_t = fluid.LoDTensor()
feature_t = fluid.LoDTensor()
label_t = fluid.LoDTensor()
...
for batch_id, data in enumerate(train_reader()):
images = data[0]
labels = data[1]
locals = data[2]
images_t.set(images, place)
labels_t.set(labels, place)
locals_t.set(locals, place)
...
报错如下:
images_t.set(images, place)
TypeError: set(): incompatible function arguments. The following argument types are supported:
1. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float32], arg1: paddle::platform::CPUPlace) -> None
2. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int32], arg1: paddle::platform::CPUPlace) -> None
3. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float64], arg1: paddle::platform::CPUPlace) -> None
4. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int64], arg1: paddle::platform::CPUPlace) -> None
5. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[bool], arg1: paddle::platform::CPUPlace) -> None
6. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint16], arg1: paddle::platform::CPUPlace) -> None
7. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint8], arg1: paddle::platform::CPUPlace) -> None
8. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float32], arg1: paddle::platform::CUDAPlace) -> None
9. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int32], arg1: paddle::platform::CUDAPlace) -> None
10. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float64], arg1: paddle::platform::CUDAPlace) -> None
11. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int64], arg1: paddle::platform::CUDAPlace) -> None
12. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[bool], arg1: paddle::platform::CUDAPlace) -> None
13. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint16], arg1: paddle::platform::CUDAPlace) -> None
14. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint8], arg1: paddle::platform::CUDAPlace) -> None
15. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float32], arg1: paddle::platform::CUDAPinnedPlace) -> None
16. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int32], arg1: paddle::platform::CUDAPinnedPlace) -> None
17. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[float64], arg1: paddle::platform::CUDAPinnedPlace) -> None
18. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[int64], arg1: paddle::platform::CUDAPinnedPlace) -> None
19. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[bool], arg1: paddle::platform::CUDAPinnedPlace) -> None
20. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint16], arg1: paddle::platform::CUDAPinnedPlace) -> None
21. (self: paddle.fluid.core.Tensor, arg0: numpy.ndarray[uint8], arg1: paddle::platform::CUDAPinnedPlace) -> None
Invoked with: <paddle.fluid.core.LoDTensor object at 0x7ff3c0531240>, (array([[[211., 223., 235., ..., 123., 125., 127.],
[204., 215., 231., ..., 116., 124., 134.],
[190., 195., 206., ..., 118., 122., 123.],
...,
[111., 115., 117., ..., 46., 51., 52.],
[118., 117., 113., ..., 39., 47., 51.],
[115., 114., 112., ..., 32., 42., 50.]],
[[235., 244., 253., ..., 179., 181., 183.],
[228., 239., 249., ..., 172., 180., 190.],
[214., 219., 227., ..., 171., 175., 176.],
...,
[121., 125., 128., ..., 49., 56., 57.],
[119., 118., 116., ..., 44., 52., 56.],
[112., 111., 112., ..., 37., 47., 55.]],
[[225., 235., 246., ..., 168., 170., 172.],
[218., 229., 242., ..., 161., 169., 179.],
[206., 211., 219., ..., 161., 166., 167.],
...,
[105., 109., 112., ..., 53., 59., 60.],
[103., 102., 100., ..., 47., 55., 59.],
[ 97., 96., 96., ..., 40., 50., 58.]]]), 5707, array([-1.20006335e+00, 3.20534378e-01, 9.33335543e-01, -4.24015141e+00,
2.13111669e-01, 9.66773868e-01, 2.46572709e+00, 5.61143541e+00,
9.39076006e-01, -4.93136793e-01, 1.56456745e+00, -1.09997416e+00,
...
最早的时候使用的是 feeder = fluid.DataFeeder(place=place, feed_list=[image, label, locals])
的方式,但是取值输出后发现读入的 locals 的值一直为NAN,而 image 和 label 的值正常