Ejemplo n.º 1
0
 def from_config(cls, config: Config, tensorizers: Dict[str, Tensorizer]):
     labels = tensorizers["labels"].labels
     embedding = cls.create_embedding(config, tensorizers)
     representation = create_module(config.representation,
                                    embed_dim=embedding.embedding_dim)
     decoder = cls.create_decoder(config, representation.representation_dim,
                                  len(labels))
     # TODO change from_config function of ClassificationOutputLayer after migriting to new design
     output_layer = ClassificationOutputLayer(
         list(labels), create_loss(config.output_layer.loss))
     return cls(embedding, representation, decoder, output_layer)
Ejemplo n.º 2
0
 def from_config(cls, config: Config, tensorizers: Dict[str, Tensorizer]):
     labels = tensorizers["labels"].labels
     embedding = cls.create_embedding(config, tensorizers)
     representation = create_module(config.representation,
                                    embed_dim=embedding.embedding_dim)
     decoder = create_module(
         config.decoder,
         in_dim=representation.representation_dim,
         out_dim=len(labels),
     )
     output_layer = ClassificationOutputLayer(labels,
                                              CrossEntropyLoss(None))
     return cls(embedding, representation, decoder, output_layer)
Ejemplo n.º 3
0
    def from_config(cls, config: Config, tensorizers: Dict[str, Tensorizer]):
        vocab = tensorizers["tokens"].vocab
        labels = tensorizers["labels"].labels

        embedding = WordEmbedding(len(vocab), config.embedding.embed_dim, None,
                                  None, vocab.idx[UNK], [])
        representation = create_module(config.representation,
                                       embed_dim=embedding.embedding_dim)
        decoder = create_module(
            config.decoder,
            in_dim=representation.representation_dim,
            out_dim=len(labels),
        )
        output_layer = ClassificationOutputLayer(labels,
                                                 CrossEntropyLoss(None))
        return cls(embedding, representation, decoder, output_layer)