首页 PaddleGAN 帖子详情
notebook说我不在动态图模式,请问怎么办?
收藏
快速回复
PaddleGAN 问答生成 433 0
notebook说我不在动态图模式,请问怎么办?
收藏
快速回复
PaddleGAN 问答生成 433 0

代码和截图如下:

ndim_1_Tensor = paddle.to_tensor([0, 1, 2, 3, 4, 5, 6, 7, 8])
print("Origin Tensor:", ndim_1_Tensor.numpy()) 
print("First element:", ndim_1_Tensor[0].numpy()) 
print("Last element:", ndim_1_Tensor[-1].numpy())
print("All element:", ndim_1_Tensor[:].numpy())
print("Before 3:", ndim_1_Tensor[:3].numpy())
print("From 6 to the end:", ndim_1_Tensor[6:].numpy())
print("From 3 to 6:", ndim_1_Tensor[3:6].numpy())
print("Interval of 3:", ndim_1_Tensor[::3].numpy())
print("Reverse:", ndim_1_Tensor[::-1].numpy())

它说'numpy' only can be called by `paddle.Tensor` in dynamic graph mode. Suggestions:
1. If you are in static graph mode, you can switch to dynamic graph mode by turning off `paddle.enable_static()` or calling `paddle.disable_static()`.
2. If you are using `@paddle.jit.to_static`, you can turn off ProgramTranslator by calling `paddle.jit.ProgramTranslator().enable(False)`. If you have to translate dynamic graph to static graph, please use other API to replace 'numpy'.

0
收藏
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户