def __init__(self, in_channel, x): super().__init__() #self._save_graphs(save_graph_flag=True, save_graph_path=".") self.biasadd = P.BiasAdd() self.equal = P.Equal() self.addn = P.AddN() self.conv = Conv2d(in_channels=in_channel, out_channels=in_channel, kernel_size=1, stride=1, has_bias=False, weight_init='ones', pad_mode='same') self.bn = BatchNorm2d(num_features=in_channel) self.assignadd = P.AssignAdd() self.assign = P.Assign() self.relu = ReLU() self.mean = P.ReduceMean(keep_dims=False) self.bias = Parameter(Tensor( np.random.randint(2, size=(3, )).astype((np.float32))), name="bias") self.bias2 = Parameter(Tensor(np.ones([3]).astype(np.float32)), name="bias2") self.parameterupdate = ParameterUpdate(self.bias) self.value = Tensor(np.random.randn(*(3, )), ms.float32) self.x = x
def __init__(self, c, weight, bias, moving_mean, moving_var_init): super(Batchnorm_Net, self).__init__() self.bn = BatchNorm2d(c, eps=0.00001, momentum=0.1, beta_init=bias, gamma_init=weight, moving_mean_init=moving_mean, moving_var_init=moving_var_init)
def __init__(self): super().__init__() self.bn1 = BatchNorm2d(num_features=4, eps=1e-4, momentum=0.9, gamma_init=1, beta_init=0, moving_mean_init=0, moving_var_init=1, data_format="NHWC") self.bn2 = BatchNorm2d(num_features=4, eps=1e-4, momentum=0.9, gamma_init=1, beta_init=0, moving_mean_init=0, moving_var_init=1, data_format="NHWC") self.add = P.Add() self.relu = ReLU() self.conv2d1 = Conv2d(in_channels=4, out_channels=4, kernel_size=2, data_format="NHWC") self.conv2d2 = Conv2d(in_channels=4, out_channels=4, kernel_size=2, data_format="NHWC") self.conv2d3 = Conv2d(in_channels=4, out_channels=4, kernel_size=2, data_format="NHWC") self.conv2d4 = Conv2d(in_channels=4, out_channels=4, kernel_size=2, data_format="NHWC")
def __init__(self, in_channels, out_channels, kernel_size, vocab_size, embedding_size, output_channels, target, sparse): super().__init__() set_seed(5) self.relu = ReLU() self.conv = Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, has_bias=True, weight_init='normal') self.batchnorm = BatchNorm2d(num_features=out_channels) self.embedding_lookup = EmbeddingLookup(vocab_size=vocab_size, embedding_size=embedding_size, param_init='normal', target=target, sparse=sparse) self.flatten = Flatten() self.cast = op.Cast() self.bias = Parameter(Tensor(np.ones([output_channels]).astype(np.float32)), name='bias') self.biasadd = op.BiasAdd() self.type = mindspore.int32
def __init__(self, in_channel, out_channel): super().__init__() self.relu = PReLU(channel=in_channel, w=0.25) self.bn = BatchNorm2d(num_features=in_channel) self.conv = Conv2d(in_channels=in_channel, out_channels=out_channel, kernel_size=2, stride=1, has_bias=False, weight_init='ones', pad_mode='same') self.mean = P.ReduceMean(keep_dims=False) self.fc = Dense(in_channels=out_channel, out_channels=out_channel, weight_init='ones', bias_init='zeros', has_bias=True)