diff --git a/official/cv/faster_rcnn/src/FasterRcnn/fpn_neck.py b/official/cv/faster_rcnn/src/FasterRcnn/fpn_neck.py index f346ccfb36c91ecf359c92c37e5492953ddd7e4e..b22da232f057ebd9a8721d84c525cb188a70b65d 100644 --- a/official/cv/faster_rcnn/src/FasterRcnn/fpn_neck.py +++ b/official/cv/faster_rcnn/src/FasterRcnn/fpn_neck.py @@ -30,7 +30,7 @@ def bias_init_zeros(shape): def _conv(in_channels, out_channels, kernel_size=3, stride=1, padding=0, pad_mode='pad'): """Conv2D wrapper.""" shape = (out_channels, in_channels, kernel_size, kernel_size) - weights = ms.common.initializer.initializer("XavierUniform", shape=shape, dtype=ms.float32).to_tensor() + weights = ms.common.initializer.initializer("XavierUniform", shape=shape, dtype=ms.float32).init_data() shape_bias = (out_channels,) biass = bias_init_zeros(shape_bias) return nn.Conv2d(in_channels, out_channels, diff --git a/official/cv/faster_rcnn/src/FasterRcnn/rcnn.py b/official/cv/faster_rcnn/src/FasterRcnn/rcnn.py index 6d68af5597e3fedf2545f29633eb300309af83d9..fa02da335afc218b02c580b5a671ce4872484f4c 100644 --- a/official/cv/faster_rcnn/src/FasterRcnn/rcnn.py +++ b/official/cv/faster_rcnn/src/FasterRcnn/rcnn.py @@ -95,18 +95,18 @@ class Rcnn(nn.Cell): shape_0 = (self.rcnn_fc_out_channels, representation_size) weights_0 = ms.common.initializer.initializer("XavierUniform", shape=shape_0[::-1], \ - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) weights_1 = ms.common.initializer.initializer("XavierUniform", shape=shape_1[::-1], \ - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = ms.common.initializer.initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = ms.common.initializer.initializer('Normal', shape=[self.num_classes_fronted * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, self.num_classes_fronted * 4, reg_weight) diff --git a/official/cv/faster_rcnn/src/FasterRcnn/rpn.py b/official/cv/faster_rcnn/src/FasterRcnn/rpn.py index 49102d76f16d278e9390ac11c8a72fd4452e244a..99bf21fa88130ad61bb0da5e3fe9be26932f173f 100644 --- a/official/cv/faster_rcnn/src/FasterRcnn/rpn.py +++ b/official/cv/faster_rcnn/src/FasterRcnn/rpn.py @@ -165,18 +165,18 @@ class RPN(nn.Cell): shp_weight_conv = (feat_channels, in_channels, 3, 3) shp_bias_conv = (feat_channels,) - weight_conv = ms.common.initializer.initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).to_tensor() - bias_conv = ms.common.initializer.initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + weight_conv = ms.common.initializer.initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).init_data() + bias_conv = ms.common.initializer.initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) - weight_cls = ms.common.initializer.initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).to_tensor() - bias_cls = ms.common.initializer.initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + weight_cls = ms.common.initializer.initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).init_data() + bias_cls = ms.common.initializer.initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) - weight_reg = ms.common.initializer.initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).to_tensor() - bias_reg = ms.common.initializer.initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + weight_reg = ms.common.initializer.initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).init_data() + bias_reg = ms.common.initializer.initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock(in_channels, feat_channels, num_anchors, cls_out_channels, \ diff --git a/research/cv/CascadeRCNN/src/CascadeRcnn/fpn_neck.py b/research/cv/CascadeRCNN/src/CascadeRcnn/fpn_neck.py index 6cf4fc9c603f91770de12284ca07dccc2384ae05..0ad3950ba69927f7fede1163c2fb588b681d6879 100644 --- a/research/cv/CascadeRCNN/src/CascadeRcnn/fpn_neck.py +++ b/research/cv/CascadeRCNN/src/CascadeRcnn/fpn_neck.py @@ -30,7 +30,7 @@ def bias_init_zeros(shape): def _conv(in_channels, out_channels, kernel_size=3, stride=1, padding=0, pad_mode='pad'): """Conv2D wrapper.""" shape = (out_channels, in_channels, kernel_size, kernel_size) - weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).to_tensor() + weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).init_data() shape_bias = (out_channels,) biass = bias_init_zeros(shape_bias) return nn.Conv2d(in_channels, out_channels, diff --git a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn.py b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn.py index d97411604aeec88201d6d7d484822c955d6960c6..00c0782183636356d71b2bc4394673bb417c6a0d 100644 --- a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn.py +++ b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn.py @@ -88,18 +88,18 @@ class Rcnn(nn.Cell): self.test_batch_size = cfg.test_batch_size shape_0 = (self.rcnn_fc_out_channels, representation_size) - weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).to_tensor() + weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) - weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).to_tensor() + weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = initializer('Normal', shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight_agn = initializer('Normal', shape=[4, self.rcnn_fc_out_channels][::-1], - dtype=mstype.float32).to_tensor() + dtype=mstype.float32).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes * 4, reg_weight) self.reg_scores_class_ang = DenseNoTranpose(self.rcnn_fc_out_channels, 4, reg_weight_agn) diff --git a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn1.py b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn1.py index 65c597c125580006cafcd4d4e2f3c82c2e0c3a43..d4330d98b4a0e17856848f0d5574c9383d76b0e6 100644 --- a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn1.py +++ b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn1.py @@ -88,18 +88,18 @@ class Rcnn_1(nn.Cell): self.test_batch_size = cfg.test_batch_size shape_0 = (self.rcnn_fc_out_channels, representation_size) - weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).to_tensor() + weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) - weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).to_tensor() + weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = initializer('Normal', shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight_agn = initializer('Normal', shape=[4, self.rcnn_fc_out_channels][::-1], - dtype=mstype.float32).to_tensor() + dtype=mstype.float32).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes * 4, reg_weight) self.reg_scores_class_ang = DenseNoTranpose(self.rcnn_fc_out_channels, 4, reg_weight_agn) diff --git a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn2.py b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn2.py index e8cd7e2364090eebf975ced481936a5f9f1fc590..06fd550021bec0d38f8b203e56d65e2351da8f53 100644 --- a/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn2.py +++ b/research/cv/CascadeRCNN/src/CascadeRcnn/rcnn2.py @@ -88,16 +88,16 @@ class Rcnn_2(nn.Cell): self.test_batch_size = cfg.test_batch_size shape_0 = (self.rcnn_fc_out_channels, representation_size) - weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).to_tensor() + weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) - weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).to_tensor() + weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = initializer('Normal', shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes * 4, reg_weight) diff --git a/research/cv/CascadeRCNN/src/CascadeRcnn/rpn.py b/research/cv/CascadeRCNN/src/CascadeRcnn/rpn.py index 5a01d2c529a1cbc3acfa829f52b337d9f281221e..ae3749f6aad64774eea4ca1801b31e0144190672 100644 --- a/research/cv/CascadeRCNN/src/CascadeRcnn/rpn.py +++ b/research/cv/CascadeRCNN/src/CascadeRcnn/rpn.py @@ -167,18 +167,18 @@ class RPN(nn.Cell): shp_weight_conv = (feat_channels, in_channels, 3, 3) shp_bias_conv = (feat_channels,) - weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).to_tensor() - bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).init_data() + bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) - weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).to_tensor() - bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).init_data() + bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) - weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).to_tensor() - bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).init_data() + bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock(in_channels, feat_channels, num_anchors, cls_out_channels, \ diff --git a/research/cv/HRNetW48_cls/src/utils.py b/research/cv/HRNetW48_cls/src/utils.py index 5cfe20f181fada9600adc8265f4d77b5874cd09a..0c7f3b0cf948d8c40cc2487f8049cf7457fe8e02 100644 --- a/research/cv/HRNetW48_cls/src/utils.py +++ b/research/cv/HRNetW48_cls/src/utils.py @@ -52,7 +52,7 @@ def calculate_fan_in_and_fan_out(shape): def get_conv_bias(cell): """Bias initializer for conv.""" weight = initializer.initializer(initializer.HeUniform(negative_slope=math.sqrt(5)), - cell.weight.shape, cell.weight.dtype).to_tensor() + cell.weight.shape, cell.weight.dtype).init_data() fan_in, _ = calculate_fan_in_and_fan_out(weight.shape) bound = 1 / math.sqrt(fan_in) return initializer.initializer(initializer.Uniform(scale=bound), diff --git a/research/cv/HRNetW48_seg/src/seg_hrnet.py b/research/cv/HRNetW48_seg/src/seg_hrnet.py index fe513c892f77074effef96ce8c892828b94984e5..1a32a75aa18bfd48abe37561fe57dc0ec768f70d 100644 --- a/research/cv/HRNetW48_seg/src/seg_hrnet.py +++ b/research/cv/HRNetW48_seg/src/seg_hrnet.py @@ -554,7 +554,7 @@ def calculate_fan_in_and_fan_out(shape): def get_conv_bias(cell): """Bias initializer for conv.""" weight = initializer.initializer(initializer.HeUniform(negative_slope=math.sqrt(5)), - cell.weight.shape, cell.weight.dtype).to_tensor() + cell.weight.shape, cell.weight.dtype).init_data() fan_in, _ = calculate_fan_in_and_fan_out(weight.shape) bound = 1 / math.sqrt(fan_in) return initializer.initializer(initializer.Uniform(scale=bound), diff --git a/research/cv/OCRNet/src/utils.py b/research/cv/OCRNet/src/utils.py index 6c5f5fc4a2f2fe64093d2ca481fc46b151629d7a..8d38e8db23133398c528acaff1a67886291d4a9d 100644 --- a/research/cv/OCRNet/src/utils.py +++ b/research/cv/OCRNet/src/utils.py @@ -47,7 +47,7 @@ def calculate_fan_in_and_fan_out(shape): def get_conv_bias(cell): weight = initializer.initializer(initializer.HeUniform(negative_slope=math.sqrt(5)), - cell.weight.shape, cell.weight.dtype).to_tensor() + cell.weight.shape, cell.weight.dtype).init_data() fan_in, _ = calculate_fan_in_and_fan_out(weight.shape) bound = 1 / math.sqrt(fan_in) return initializer.initializer(initializer.Uniform(scale=bound), diff --git a/research/cv/advanced_east/src/vgg.py b/research/cv/advanced_east/src/vgg.py index 6f608aeed71d46c0547b6891bd3f34718d57f747..930eb5aa2e9d61ed31b952bc7a2ad4dd83412723 100644 --- a/research/cv/advanced_east/src/vgg.py +++ b/research/cv/advanced_east/src/vgg.py @@ -38,7 +38,7 @@ def _make_layer(base, args, batch_norm): weight = 'ones' if args.initialize_mode == "XavierUniform": weight_shape = (v, in_channels, 3, 3) - weight = initializer('XavierUniform', shape=weight_shape, dtype=mstype.float32).to_tensor() + weight = initializer('XavierUniform', shape=weight_shape, dtype=mstype.float32).init_data() conv2d = nn.Conv2d(in_channels=in_channels, out_channels=v, diff --git a/research/cv/efficientnet-b1/src/utils.py b/research/cv/efficientnet-b1/src/utils.py index 3f63a075b661fb5254388e6635be8d87419ae3ed..7ddd11d279ecb2c48b6154eba6e619deb2ab0a1b 100644 --- a/research/cv/efficientnet-b1/src/utils.py +++ b/research/cv/efficientnet-b1/src/utils.py @@ -52,7 +52,7 @@ def calculate_fan_in_and_fan_out(shape): def get_conv_bias(cell): """Bias initializer for conv.""" weight = initializer.initializer(initializer.HeUniform(negative_slope=math.sqrt(5)), - cell.weight.shape, cell.weight.dtype).to_tensor() + cell.weight.shape, cell.weight.dtype).init_data() fan_in, _ = calculate_fan_in_and_fan_out(weight.shape) bound = 1 / math.sqrt(fan_in) return initializer.initializer(initializer.Uniform(scale=bound), diff --git a/research/cv/faster_rcnn_dcn/src/FasterRcnn/fpn_neck.py b/research/cv/faster_rcnn_dcn/src/FasterRcnn/fpn_neck.py index 0aedcefae9c773b5774a460a073ef35233044d20..c2916f285628d4c5e31de8cef9cc474e819c3ae8 100644 --- a/research/cv/faster_rcnn_dcn/src/FasterRcnn/fpn_neck.py +++ b/research/cv/faster_rcnn_dcn/src/FasterRcnn/fpn_neck.py @@ -30,7 +30,7 @@ def bias_init_zeros(shape): def _conv(in_channels, out_channels, kernel_size=3, stride=1, padding=0, pad_mode='pad'): """Conv2D wrapper.""" shape = (out_channels, in_channels, kernel_size, kernel_size) - weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).to_tensor() + weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).init_data() shape_bias = (out_channels,) biass = bias_init_zeros(shape_bias) return nn.Conv2d(in_channels, out_channels, diff --git a/research/cv/faster_rcnn_dcn/src/FasterRcnn/rcnn.py b/research/cv/faster_rcnn_dcn/src/FasterRcnn/rcnn.py index 0c1cf0b8f530c1bb67069898ddd33193bde94101..11defd618a8618d7aa3fab32500368132264f951 100644 --- a/research/cv/faster_rcnn_dcn/src/FasterRcnn/rcnn.py +++ b/research/cv/faster_rcnn_dcn/src/FasterRcnn/rcnn.py @@ -88,16 +88,16 @@ class Rcnn(nn.Cell): self.test_batch_size = cfg.test_batch_size shape_0 = (self.rcnn_fc_out_channels, representation_size) - weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).to_tensor() + weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) - weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).to_tensor() + weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = initializer('Normal', shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes * 4, reg_weight) diff --git a/research/cv/faster_rcnn_dcn/src/FasterRcnn/rpn.py b/research/cv/faster_rcnn_dcn/src/FasterRcnn/rpn.py index 2f9d2f84799814e01d674bae49b6080715302382..f8e324a66248e16fd680a1bd6aba9b71a3c4ab5f 100644 --- a/research/cv/faster_rcnn_dcn/src/FasterRcnn/rpn.py +++ b/research/cv/faster_rcnn_dcn/src/FasterRcnn/rpn.py @@ -168,18 +168,18 @@ class RPN(nn.Cell): shp_weight_conv = (feat_channels, in_channels, 3, 3) shp_bias_conv = (feat_channels,) - weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).to_tensor() - bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).init_data() + bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) - weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).to_tensor() - bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).init_data() + bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) - weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).to_tensor() - bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).init_data() + bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock(in_channels, feat_channels, num_anchors, cls_out_channels, \ diff --git a/research/cv/res2net_faster_rcnn/src/FasterRcnn/fpn_neck.py b/research/cv/res2net_faster_rcnn/src/FasterRcnn/fpn_neck.py index 2e8c9a01a0fb0f12d48b6cd5ed4a91a09560173e..f11383c0ec180f774f9f683ab3e8fe44fac6e996 100644 --- a/research/cv/res2net_faster_rcnn/src/FasterRcnn/fpn_neck.py +++ b/research/cv/res2net_faster_rcnn/src/FasterRcnn/fpn_neck.py @@ -34,7 +34,7 @@ def _conv( shape = (out_channels, in_channels, kernel_size, kernel_size) weights = initializer( "XavierUniform", shape=shape, dtype=mstype.float32 - ).to_tensor() + ).init_data() shape_bias = (out_channels,) biass = bias_init_zeros(shape_bias) return nn.Conv2d( diff --git a/research/cv/res2net_faster_rcnn/src/FasterRcnn/rcnn.py b/research/cv/res2net_faster_rcnn/src/FasterRcnn/rcnn.py index 4d1843b43251b4faf324a3407452fff9c983833d..2fc6c5b476fb7082826e8157bde622dcb3f76104 100644 --- a/research/cv/res2net_faster_rcnn/src/FasterRcnn/rcnn.py +++ b/research/cv/res2net_faster_rcnn/src/FasterRcnn/rcnn.py @@ -101,11 +101,11 @@ class Rcnn(nn.Cell): shape_0 = (self.rcnn_fc_out_channels, representation_size) weights_0 = initializer( "XavierUniform", shape=shape_0[::-1], dtype=self.ms_type - ).to_tensor() + ).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) weights_1 = initializer( "XavierUniform", shape=shape_1[::-1], dtype=self.ms_type - ).to_tensor() + ).init_data() self.shared_fc_0 = DenseNoTranpose( representation_size, self.rcnn_fc_out_channels, weights_0 ) @@ -117,12 +117,12 @@ class Rcnn(nn.Cell): "Normal", shape=[num_classes, self.rcnn_fc_out_channels][::-1], dtype=self.ms_type, - ).to_tensor() + ).init_data() reg_weight = initializer( "Normal", shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], dtype=self.ms_type, - ).to_tensor() + ).init_data() self.cls_scores = DenseNoTranpose( self.rcnn_fc_out_channels, num_classes, cls_weight ) diff --git a/research/cv/res2net_faster_rcnn/src/FasterRcnn/rpn.py b/research/cv/res2net_faster_rcnn/src/FasterRcnn/rpn.py index 1b0f4217be3609206fa7c3269d6d0eeeaea33ac4..ffbd2b0614c6d866baad2228bc0f4d301253b361 100644 --- a/research/cv/res2net_faster_rcnn/src/FasterRcnn/rpn.py +++ b/research/cv/res2net_faster_rcnn/src/FasterRcnn/rpn.py @@ -220,22 +220,22 @@ class RPN(nn.Cell): shp_bias_conv = (feat_channels,) weight_conv = initializer( "Normal", shape=shp_weight_conv, dtype=self.ms_type - ).to_tensor() - bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + ).init_data() + bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) weight_cls = initializer( "Normal", shape=shp_weight_cls, dtype=self.ms_type - ).to_tensor() - bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + ).init_data() + bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) weight_reg = initializer( "Normal", shape=shp_weight_reg, dtype=self.ms_type - ).to_tensor() - bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + ).init_data() + bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock( diff --git a/research/cv/rfcn/src/rfcn/rpn.py b/research/cv/rfcn/src/rfcn/rpn.py index 3e2a5f4c59519d4eff7371931f5d301cac4a7479..a3d7e8391fe51a3e631acc723f46fad6355dee7c 100644 --- a/research/cv/rfcn/src/rfcn/rpn.py +++ b/research/cv/rfcn/src/rfcn/rpn.py @@ -166,18 +166,18 @@ class RPN(nn.Cell): shp_weight_conv = (feat_channels, in_channels, 3, 3) shp_bias_conv = (feat_channels,) - weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).to_tensor() - bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).init_data() + bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) - weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).to_tensor() - bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).init_data() + bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) - weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).to_tensor() - bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).init_data() + bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock(in_channels, feat_channels, num_anchors, cls_out_channels, \ diff --git a/research/cv/tracktor/src/FasterRcnn/fpn_neck.py b/research/cv/tracktor/src/FasterRcnn/fpn_neck.py index 8496b8636e16fa48ecdd14ef93f27ea2e24dcdc7..0cf8e819de896be8be73f3e028a59e9a0de918d3 100644 --- a/research/cv/tracktor/src/FasterRcnn/fpn_neck.py +++ b/research/cv/tracktor/src/FasterRcnn/fpn_neck.py @@ -31,7 +31,7 @@ def bias_init_zeros(shape): def _conv(in_channels, out_channels, kernel_size=3, stride=1, padding=0, pad_mode='pad'): """Conv2D wrapper.""" shape = (out_channels, in_channels, kernel_size, kernel_size) - weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).to_tensor() + weights = initializer("XavierUniform", shape=shape, dtype=mstype.float32).init_data() shape_bias = (out_channels,) biass = bias_init_zeros(shape_bias) return nn.Conv2d(in_channels, out_channels, diff --git a/research/cv/tracktor/src/FasterRcnn/rcnn.py b/research/cv/tracktor/src/FasterRcnn/rcnn.py index 89a71c03dbcc2d74a4f899177adb8c6951e662ca..599895b8e812776f30286297740fdd5aac7500eb 100644 --- a/research/cv/tracktor/src/FasterRcnn/rcnn.py +++ b/research/cv/tracktor/src/FasterRcnn/rcnn.py @@ -88,16 +88,16 @@ class Rcnn(nn.Cell): self.test_batch_size = cfg.test_batch_size shape_0 = (self.rcnn_fc_out_channels, representation_size) - weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).to_tensor() + weights_0 = initializer("XavierUniform", shape=shape_0[::-1], dtype=self.ms_type).init_data() shape_1 = (self.rcnn_fc_out_channels, self.rcnn_fc_out_channels) - weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).to_tensor() + weights_1 = initializer("XavierUniform", shape=shape_1[::-1], dtype=self.ms_type).init_data() self.shared_fc_0 = DenseNoTranpose(representation_size, self.rcnn_fc_out_channels, weights_0) self.shared_fc_1 = DenseNoTranpose(self.rcnn_fc_out_channels, self.rcnn_fc_out_channels, weights_1) cls_weight = initializer('Normal', shape=[num_classes, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() reg_weight = initializer('Normal', shape=[num_classes * 4, self.rcnn_fc_out_channels][::-1], - dtype=self.ms_type).to_tensor() + dtype=self.ms_type).init_data() self.cls_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes, cls_weight) self.reg_scores = DenseNoTranpose(self.rcnn_fc_out_channels, num_classes * 4, reg_weight) diff --git a/research/cv/tracktor/src/FasterRcnn/rpn.py b/research/cv/tracktor/src/FasterRcnn/rpn.py index f4c92caf1a013f309dceb88a87cca666c00fcdaa..0cc498238acdba1aa39cfefe07209c794f5f1f9d 100644 --- a/research/cv/tracktor/src/FasterRcnn/rpn.py +++ b/research/cv/tracktor/src/FasterRcnn/rpn.py @@ -167,18 +167,18 @@ class RPN(nn.Cell): shp_weight_conv = (feat_channels, in_channels, 3, 3) shp_bias_conv = (feat_channels,) - weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).to_tensor() - bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).to_tensor() + weight_conv = initializer('Normal', shape=shp_weight_conv, dtype=self.ms_type).init_data() + bias_conv = initializer(0, shape=shp_bias_conv, dtype=self.ms_type).init_data() shp_weight_cls = (num_anchors * cls_out_channels, feat_channels, 1, 1) shp_bias_cls = (num_anchors * cls_out_channels,) - weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).to_tensor() - bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).to_tensor() + weight_cls = initializer('Normal', shape=shp_weight_cls, dtype=self.ms_type).init_data() + bias_cls = initializer(0, shape=shp_bias_cls, dtype=self.ms_type).init_data() shp_weight_reg = (num_anchors * 4, feat_channels, 1, 1) shp_bias_reg = (num_anchors * 4,) - weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).to_tensor() - bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).to_tensor() + weight_reg = initializer('Normal', shape=shp_weight_reg, dtype=self.ms_type).init_data() + bias_reg = initializer(0, shape=shp_bias_reg, dtype=self.ms_type).init_data() for i in range(num_layers): rpn_reg_cls_block = RpnRegClsBlock(in_channels, feat_channels, num_anchors, cls_out_channels, \