def forward(self, x): x = self.decoder_unpool0(x) p = self.decoder_block0(x) x = F.leaky_relu(x + p) x = self.decoder_unpool1(x) p = self.decoder_block1(x) x = F.leaky_relu(x + p) x = self.decoder_unpool2(x) p1 = self.decoder_block2(x) p2 = self.decoder_block2_shortcut(x) x = F.leaky_relu(p1 + p2) p1 = self.decoder_block3(x) p2 = self.decoder_block3_shortcut(x) x = F.leaky_relu(p1 + p2) x = self.decoder_block4(x) # x = x[:,0,:,:,:] # x = F.softmax(x, axis=1) x = paddle.sum(x, axis=1) x = paddle.clip(x, min=0, max=1) return x
def fused_leaky_relu(input, bias=None, negative_slope=0.2, scale=2**0.5): if bias is not None: rest_dim = [1] * (input.ndim - bias.ndim - 1) return (F.leaky_relu(input + bias.reshape( (1, bias.shape[0], *rest_dim)), negative_slope=0.2) * scale) else: return F.leaky_relu(input, negative_slope=0.2) * scale
def forward(self, x): x = self.conv_1(x) x = F.leaky_relu(x,negative_slope=0.2) x = self.conv_2(x) x = self.bn_2(x) x = F.leaky_relu(x,negative_slope=0.2) x = self.conv_3(x) x = self.bn_3(x) x = F.leaky_relu(x,negative_slope=0.2) x = self.conv_4(x) x = self.bn_4(x) x = F.leaky_relu(x,negative_slope=0.2) x = self.conv_5(x) x = F.sigmoid(x) return x
def forward(self, x, trim_conv_artifact=False): r"""Forward pass of the ``UpsampleNet``. Parameters ----------- x : Tensor [shape=(batch_size, input_channels, time_steps)] The input spectrogram. trim_conv_artifact : bool, optional Trim deconvolution artifact at each layer. Defaults to False. Returns -------- Tensor: [shape=(batch_size, input_channels, time_steps \* upsample_factor)] The upsampled spectrogram. Notes -------- If trim_conv_artifact is ``True``, the output time steps is less than ``time_steps \* upsample_factors``. """ x = paddle.unsqueeze(x, 1) #(B, C, T) -> (B, 1, C, T) for layer in self: x = layer(x) if trim_conv_artifact: time_cutoff = layer._kernel_size[1] - layer._stride[1] x = x[:, :, :, :-time_cutoff] x = F.leaky_relu(x, 0.4) x = paddle.squeeze(x, 1) # back to (B, C, T) return x
def forward(self, x): x = self.bn(self.conv(x)) if self.act == "leaky_relu": x = F.leaky_relu(x) elif self.act == "hard_swish": x = F.hardswish(x) return x
def forward(self, inputs): out = self.conv(inputs) out = self.batch_norm(out) if self.act == 'leaky': out = F.leaky_relu(out, 0.1) else: out = getattr(F, self.act)(out) return out
def forward(self, inputs): out = self.conv(inputs) out = self.batch_norm(out) if self.act == 'leaky': out = F.leaky_relu(out, 0.1) elif self.act == 'mish': out = mish(out) return out
def forward(self, inputs): y = self._conv(inputs) y = self._batch_norm(y) if self.act == 'leaky': y = F.leaky_relu(x=y, negative_slope=0.1) elif self.act == 'relu': y = F.relu(x=y) return y
def forward(self, x): out = x if self.sn is not None: self.conv.weight.set_value(self.sn(self.conv.weight)) out = self.conv(out) if self.norm is not None: out = self.norm(out) out = F.leaky_relu(out, 0.2) if self.pool: out = F.avg_pool2d(out, kernel_size=2, stride=2, ceil_mode=False) return out
def forward(self, inputs): y = self.conv0(inputs) conv1 = self.conv1(y) if self.shortcut: short = inputs else: short = self.short(inputs) y = paddle.add(short, conv1) y = F.leaky_relu(y) return y
def forward(self, x): x = self.decoder_unpool0(x) p = self.decoder_block0(x) x = F.leaky_relu(x + p) x = self.decoder_unpool1(x) p = self.decoder_block1(x) x = F.leaky_relu(x + p) x = self.decoder_unpool2(x) p1 = self.decoder_block2(x) p2 = self.decoder_block2_shortcut(x) x = F.leaky_relu(p1 + p2) p1 = self.decoder_block3(x) p2 = self.decoder_block3_shortcut(x) x = F.leaky_relu(p1 + p2) x = self.decoder_block4(x) return x
def forward(self, x): x = self._conv(x) x = self._batch_norm(x) if self.act == "relu": x = F.relu(x) elif self.act == "relu6": x = F.relu6(x) elif self.act == 'leaky': x = F.leaky_relu(x) elif self.act == 'hard_swish': x = hard_swish(x) return x
def forward(self, inputs): shifts = paddle.fluid.layers.temporal_shift(inputs, self.num_seg, 1.0 / self.num_seg) y = self.conv0(shifts) conv1 = self.conv1(y) conv2 = self.conv2(conv1) if self.shortcut: short = inputs else: short = self.short(inputs) y = paddle.add(x=short, y=conv2) return F.leaky_relu(y)
def forward(self, inputs): conv = self.conv(inputs) if self.norm: conv = self.bn(conv) if self.act == 'leaky_relu': conv = F.leaky_relu(conv, self.relufactor) elif self.act == 'relu': conv = F.relu(conv) else: conv = conv return conv
def forward(self, inputs): conv = self._deconv(inputs) conv = F.pad2d(conv, paddings=self.outpadding, mode='constant', pad_value=0.0) if self.norm: conv = self.bn(conv) if self.act == 'leaky_relu': conv = F.leaky_relu(conv, self.relufactor) elif self.act == 'relu': conv = F.relu(conv) else: conv = conv return conv
def forward(self, x): r"""Compute the upsampled condition. Parameters ----------- x : Tensor [shape=(B, F, T)] The condition (mel spectrogram here). ``F`` means the frequency bands, which is the feature size of the input. In the internal Conv2DTransposes, the frequency dimension is treated as ``height`` dimension instead of ``in_channels``. Returns: Tensor [shape=(B, F, T \* upscale_factor)] The upsampled condition. """ x = paddle.unsqueeze(x, 1) for sublayer in self: x = F.leaky_relu(sublayer(x), 0.4) x = paddle.squeeze(x, 1) return x
def forward(self, inputs): out = self.conv(inputs) out = self.batch_norm(out) if self.act == 'leaky': out = F.leaky_relu(x=out, negative_slope=0.1) return out
def forward(self, inputs: paddle.Tensor) -> paddle.Tensor: out = self.conv(inputs) out = self.batch_norm(out) if self.act == "leakly": out = F.leaky_relu(x=out, negative_slope=0.1) return out
def act_func(self, x): if self.act == "leaky_relu": x = F.leaky_relu(x) elif self.act == "hard_swish": x = F.hardswish(x) return x