Ejemplo n.º 1
0
 def __init__(self, nfeats, noutputs, nlayers=4):
     super().__init__()
     encoder_layer = transformer.TransformerEncoderLayer(
         nfeats + 16, 2, nfeats)
     decoder_layer = transformer.TransformerDecoderLayer(
         nfeats + 16, 2, nfeats)
     self.encoder = transformer.TransformerEncoder(encoder_layer, nlayers)
     self.decoder = transformer.TransformerDecoder(decoder_layer, nlayers)
     self.predict_outputs = nn.Linear(nfeats + 16, noutputs)
Ejemplo n.º 2
0
 def __init__(self, dim_model, num_heads, dim_feedforward, num_layers):
     super().__init__()
     assert num_layers >= 1
     self.layers = nn.ModuleList([
         transformer.TransformerDecoderLayer(
             d_model=dim_model,
             nhead=num_heads,
             dim_feedforward=dim_feedforward,
             dropout=0.0,
         ) for _ in range(num_layers - 1)
     ] + [
         DecoderLastLayerPytorch(
             d_model=dim_model,
             nhead=num_heads,
             dim_feedforward=dim_feedforward,
             dropout=0.0,
         )
     ])
     self.num_layers = num_layers