Пример #1
0
 def test_loss_model4(self):
     layer_dim = 512
     model = DefaultTranslator(
         src_reader=self.src_reader,
         trg_reader=self.trg_reader,
         src_embedder=SimpleWordEmbedder(emb_dim=layer_dim, vocab_size=100),
         encoder=BiLSTMSeqTransducer(input_dim=layer_dim,
                                     hidden_dim=layer_dim),
         attender=DotAttender(),
         trg_embedder=SimpleWordEmbedder(emb_dim=layer_dim, vocab_size=100),
         decoder=MlpSoftmaxDecoder(input_dim=layer_dim,
                                   trg_embed_dim=layer_dim,
                                   rnn_layer=UniLSTMSeqTransducer(
                                       input_dim=layer_dim,
                                       hidden_dim=layer_dim,
                                       decoder_input_dim=layer_dim,
                                       yaml_path="model.decoder.rnn_layer"),
                                   mlp_layer=MLP(
                                       input_dim=layer_dim,
                                       hidden_dim=layer_dim,
                                       decoder_rnn_dim=layer_dim,
                                       vocab_size=100,
                                       yaml_path="model.decoder.rnn_layer"),
                                   bridge=CopyBridge(dec_dim=layer_dim,
                                                     dec_layers=1)),
     )
     model.set_train(False)
     self.assert_single_loss_equals_batch_loss(model)
Пример #2
0
 def test_loss_model4(self):
     model = DefaultTranslator(
         src_embedder=SimpleWordEmbedder(self.model_context,
                                         vocab_size=100),
         encoder=BiLSTMSeqTransducer(self.model_context),
         attender=DotAttender(self.model_context),
         trg_embedder=SimpleWordEmbedder(self.model_context,
                                         vocab_size=100),
         decoder=MlpSoftmaxDecoder(self.model_context, vocab_size=100),
     )
     model.set_train(False)
     self.assert_single_loss_equals_batch_loss(model)
Пример #3
0
 def test_loss_model4(self):
     model = DefaultTranslator(
         src_reader=self.src_reader,
         trg_reader=self.trg_reader,
         src_embedder=SimpleWordEmbedder(self.exp_global, vocab_size=100),
         encoder=BiLSTMSeqTransducer(self.exp_global),
         attender=DotAttender(self.exp_global),
         trg_embedder=SimpleWordEmbedder(self.exp_global, vocab_size=100),
         decoder=MlpSoftmaxDecoder(self.exp_global,
                                   vocab_size=100,
                                   bridge=CopyBridge(
                                       exp_global=self.exp_global,
                                       dec_layers=1)),
     )
     model.set_train(False)
     self.assert_single_loss_equals_batch_loss(model)
Пример #4
0
 def test_loss_model4(self):
   layer_dim = 512
   model = DefaultTranslator(
     src_reader=self.src_reader,
     trg_reader=self.trg_reader,
     src_embedder=SimpleWordEmbedder(emb_dim=layer_dim, vocab_size=100),
     encoder=BiLSTMSeqTransducer(input_dim=layer_dim, hidden_dim=layer_dim),
     attender=DotAttender(),
     trg_embedder=SimpleWordEmbedder(emb_dim=layer_dim, vocab_size=100),
     decoder=AutoRegressiveDecoder(input_dim=layer_dim,
                               trg_embed_dim=layer_dim,
                               rnn=UniLSTMSeqTransducer(input_dim=layer_dim,
                                                              hidden_dim=layer_dim,
                                                              decoder_input_dim=layer_dim,
                                                              yaml_path="model.decoder.rnn"),
                               transform=NonLinear(input_dim=layer_dim*2, output_dim=layer_dim),
                               scorer=Softmax(input_dim=layer_dim, vocab_size=100),
                               bridge=CopyBridge(dec_dim=layer_dim, dec_layers=1)),
   )
   model.set_train(False)
   self.assert_single_loss_equals_batch_loss(model)