Browse Source

for pylint 4th

tags/v0.3.0-alpha
z00478463 6 years ago
parent
commit
13321abf7e
3 changed files with 19 additions and 18 deletions
  1. +1
    -1
      example/resnet50_imagenet2012_THOR/cus_ops/cus_transpose02314.py
  2. +17
    -16
      example/resnet50_imagenet2012_THOR/model/thor_layer.py
  3. +1
    -1
      example/resnet50_imagenet2012_THOR/train.py

+ 1
- 1
example/resnet50_imagenet2012_THOR/cus_ops/cus_transpose02314.py View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""CusTranspose02314"""

from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from mindspore.ops.composite import multitype_ops as C


+ 17
- 16
example/resnet50_imagenet2012_THOR/model/thor_layer.py View File

@@ -37,13 +37,14 @@ C0 = 16


def caculate_device_shape(matrix_dim, channel, is_A):
ll = (0)
if is_A:
if channel // C0 == 0:
matrix_dim = (matrix_dim / channel) * C0
return (int(matrix_dim // C0), int(matrix_dim // C0), C0, C0), int(matrix_dim)
ll = (int(matrix_dim // C0), int(matrix_dim // C0), C0, C0), int(matrix_dim)
else:
return (int(matrix_dim // C0), int(matrix_dim // C0), C0, C0), int(matrix_dim)
ll = (int(matrix_dim // C0), int(matrix_dim // C0), C0, C0), int(matrix_dim)
return ll

class _Conv(Cell):
r"""Applies a N-D convolution over an input signal composed of several input
@@ -91,7 +92,7 @@ class _Conv(Cell):
'attr \'group\' of \'Conv2D\' Op.')

self.weight = Parameter(initializer(
weight_init, [out_channels, in_channels // group, *kernel_size]), name='weight')
weight_init, [out_channels, in_channels // group, *kernel_size]), name='weight')

if check_bool(has_bias):
self.bias = Parameter(_initializer(
@@ -311,18 +312,18 @@ class Conv2d_Thor(_Conv):
'stride={}, pad_mode={}, padding={}, dilation={}, ' \
'group={}, data_format={}, has_bias={},' \
'weight_init={}, bias_init={}'.format(
self.in_channels,
self.out_channels,
self.kernel_size,
self.stride,
self.pad_mode,
self.padding,
self.dilation,
self.group,
self.data_format,
self.has_bias,
self.weight,
self.bias)
self.in_channels,
self.out_channels,
self.kernel_size,
self.stride,
self.pad_mode,
self.padding,
self.dilation,
self.group,
self.data_format,
self.has_bias,
self.weight,
self.bias)

if self.has_bias:
s += ', bias={}'.format(self.bias)


+ 1
- 1
example/resnet50_imagenet2012_THOR/train.py View File

@@ -125,7 +125,7 @@ if __name__ == '__main__':
else:
lr = Tensor(get_lr(global_step=0, lr_init=config.lr_init, lr_end=config.lr_end, lr_max=config.lr_max,
warmup_epochs=config.warmup_epochs, total_epochs=epoch_size, steps_per_epoch=step_size,
lr_decay_mode='poly'))
))
opt = THOR(filter(lambda x: x.requires_grad, net.get_parameters()), lr,
config.momentum, damping, config.frequency,
filter(lambda x: 'matrix_A' in x.name, net.get_parameters()),


Loading…
Cancel
Save