• Docs >
  • Module code >
  • mmedit.models.backbones.encoder_decoders.simple_encoder_decoder
Shortcuts

Source code for mmedit.models.backbones.encoder_decoders.simple_encoder_decoder

# Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn

from mmedit.models.builder import build_component
from mmedit.models.registry import BACKBONES


[docs]@BACKBONES.register_module() class SimpleEncoderDecoder(nn.Module): """Simple encoder-decoder model from matting. Args: encoder (dict): Config of the encoder. decoder (dict): Config of the decoder. """ def __init__(self, encoder, decoder): super().__init__() self.encoder = build_component(encoder) if hasattr(self.encoder, 'out_channels'): decoder['in_channels'] = self.encoder.out_channels self.decoder = build_component(decoder) def init_weights(self, pretrained=None): self.encoder.init_weights(pretrained) self.decoder.init_weights()
[docs] def forward(self, *args, **kwargs): """Forward function. Returns: Tensor: The output tensor of the decoder. """ out = self.encoder(*args, **kwargs) out = self.decoder(out) return out
Read the Docs v: v0.13.0
Versions
latest
stable
v0.13.0
v0.12.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.