请问一下,这行代码在静态图里如何实现
Created by: zhengzhe97
Variable是否有办法来当成索引
def get_segment_t_tensor(mask_t, cur_class_t, cur_num):
downsampled_masks = fluid.layers.squeeze(
fluid.layers.resize_bilinear(
fluid.layers.unsqueeze(input=mask_t, axes=[0]),
out_shape=[72, 72]),
axes=[0])
downsampled_masks = fluid.layers.cast(downsampled_masks > 0.5, 'float32')
segment_t = fluid.layers.zeros(shape=[81, 72, 72], dtype='float32')
r = fluid.layers.range(0, fluid.layers.shape(downsampled_masks)[0], 1, dtype='int32')
for obj_idx in range(50):
segment_t[cur_class_t[obj_idx]] = fluid.layers.elementwise_max(segment_t[cur_class_t[obj_idx]], downsampled_masks[obj_idx])
return segment_t
Traceback (most recent call last):
File "tools/train.py", line 323, in <module>
main()
File "tools/train.py", line 116, in main
train_fetches = model.train(feed_vars)
File "/home/aistudio/work/PaddleDetection-release-0.2/ppdet/modeling/architectures/yolactplus.py", line 98, in train
return self.build(feed_vars, 'train')
File "/home/aistudio/work/PaddleDetection-release-0.2/ppdet/modeling/architectures/yolactplus.py", line 88, in build
gt_box, gt_class, gt_segm, is_crowd, gt_num)
File "/home/aistudio/work/PaddleDetection-release-0.2/ppdet/modeling/anchor_heads/yolact_head.py", line 733, in get_loss
losses['S'] = self.semantic_segmentation_loss(segm_pred_reshape_list, gt_mask, labels, batch_size, gt_num)
File "/home/aistudio/work/PaddleDetection-release-0.2/ppdet/modeling/anchor_heads/yolact_head.py", line 823, in semantic_segmentation_loss
t = get_segment_t_tensor(mask_t[idx], cur_class_t, cur_num)
File "/home/aistudio/work/PaddleDetection-release-0.2/ppdet/modeling/anchor_heads/yolact_head.py", line 1162, in get_segment_t_tensor
segment_t[cur_class_t[obj_idx]] = fluid.layers.elementwise_max(segment_t[cur_class_t[obj_idx]], downsampled_masks[obj_idx])
TypeError: 'Variable' object does not support item assignment