Code Monkey home page Code Monkey logo

style-transfer-through-back-translation's People

Contributors

shrimai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

style-transfer-through-back-translation's Issues

Issue in train_decoder.py

Hi!

After your previous suggestion, I modified my commands and they run perfectly now!
However, there are some problems I faced with the train_decoder.py file.
It showed the error -

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

while trying to load the model in line 323.

I made the following changes to the train_decoder.py before loading the model -

from functools import partial
import pickle
pickle.load = partial(pickle.load, encoding="latin1")
pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
dataset = torch.load(model_file, pickle_module=pickle)

and now it seems to work.
Is this error system dependent? or any other reason why it might be occuring on just my system?

Unavailability of rebublican_only.test.fr

Hi!

I was trying to run the style_decoder/example.sh script and ran into a problem.

The last line of style_decoder/example.sh is:

python translate.py -encoder_model ../models/translation/french_english/french_english.pt -decoder_model ../models/style_generators/democratic_generator.pt -src ../data/political_data/republican_only.test.fr -output trained_models/republican_democratic.txt -replace_unk $true

However, in the README.md, there is no mention of how to obtain the file rebublican_only.test.fr.

Could you please share how can I obtain this file?

Incredibly high perplexity with Translator_Style

We're getting results with an Average score of -6.4762 and a prediction perplexity of 649.4811 while translating the republican test set (from French to English) for style generation (the last line in example.sh). We are using the best model downloaded in models/style_generator. What is the reason for this?

Missing `political_classifier_vocab.src.dict`

Would it be possible to provide this in the http://tts.speech.cs.cmu.edu/style_models/political_data.tar file?

When I run this line:

python preprocess.py -train_src ../data/political_data/democratic_only.train.fr -train_tgt ../data/political_data/democratic_only.train.en -valid_src ../data/political_data/democratic_only.dev.fr -valid_tgt ../data/political_data/democratic_only.dev.en -save_data data/democratic_generator -src_vocab ../models/translation/french_english/french_english_vocab.src.dict -tgt_vocab ../models/classifier/political_classifier/political_classifier_vocab.src.dict -seq_len 50

I get

(backstyle) johnchen@vws53:~/Desktop/git_stuff/Style-Transfer-Through-Back-Translation/style_decoder$ python preprocess.py -train_src ../data/political_data/democratic_only.train.fr -train_tgt ../data/political_data/democratic_only.train.en -valid_src ../data/political_data/democratic_only.dev.fr -valid_tgt ../data/political_data/democratic_only.dev.en -save_data data/democratic_generator -src_vocab ../models/translation/french_english/french_english_vocab.src.dict -tgt_vocab ../models/classifier/political_classifier/political_classifier_vocab.src.dict -seq_len 50
Preparing source vocab ....
Reading source vocabulary from '../models/translation/french_english/french_english_vocab.src.dict'...
Loaded 100004 source words

Preparing target vocab ....
Reading target vocabulary from '../models/classifier/political_classifier/political_classifier_vocab.src.dict'...
Traceback (most recent call last):
  File "preprocess.py", line 238, in <module>
    main()
  File "preprocess.py", line 178, in main
    opt.tgt_vocab_size)
  File "preprocess.py", line 76, in initVocabulary
    vocab.loadFile(vocabFile)
  File "/h/johnchen/Desktop/git_stuff/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dict.py", line 25, in loadFile
    for line in open(filename):
FileNotFoundError: [Errno 2] No such file or directory: '../models/classifier/political_classifier/political_classifier_vocab.src.dict'

From my understanding, you can also generate this source voacb dict from training the classifier; however, in that case could we get the dev.txt file provided?

Thanks!

Assertion Error during trying to use gpus of train_decoder.py

Hi,
I am following commands in style_decoder/example.sh and come to this line

python train_decoder.py -data ../data/democratic_generator.train.pt -save_model trained_models/democratic_generator -classifier_model ../models/classifier/political_classifier/political_classifier.pt -encoder_model ../models/translation/french_english/french_english.pt -tgt_label 1

It seems working fine but when I try to use gpu, the following command:

python train_decoder.py -data ../data/democratic_generator.train.pt -save_model trained_models/democratic_generator -classifier_model ../models/classifier/political_classifier/political_classifier.pt -encoder_model ../models/translation/french_english/french_english.pt -tgt_label 1 -gpus 0

gives me error message:

Namespace(batch_size=64, brnn=True, brnn_merge='concat', class_weight=1.0, classifier_model='../models/classifier/political_classifier/political_classifier.pt', curriculum=False, data='../data/democratic_generator.train.pt', dropout=0.3, encoder_model='../models/translation/french_english/french_english.pt', epochs=13, extra_shuffle=False, gpus=[0], input_feed=1, layers=2, learning_rate=1.0, learning_rate_decay=0.5, log_interval=50, max_generator_batches=32, max_grad_norm=5, nll_weight=1.0, optim='sgd', param_init=0.1, pre_word_vecs_dec=None, pre_word_vecs_enc=None, rnn_size=500, save_model='trained_models/democratic_generator', sequence_length=50, start_decay_at=8, start_epoch=1, temperature=1.0, tgt_label=1, train_from='', train_from_state_dict='', word_vec_size=300)
Loading data from '../data/democratic_generator.train.pt'

  • vocabulary size. source = 100004; target = 20004
  • number of training sentences. 260170
  • maximum batch size. 64
    Loading Encoder Model ...
    Loading CNN Classifier Model ...
    Building model...
    Traceback (most recent call last):
    File "train_decoder.py", line 437, in
    main()
    File "train_decoder.py", line 387, in main
    encoder.cuda()
    File "/home/kouhakuken0609/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 216, in cuda
    return self._apply(lambda t: t.cuda(device))
    File "/home/kouhakuken0609/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 146, in _apply
    module._apply(fn)
    File "/home/kouhakuken0609/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 123, in _apply
    self.flatten_parameters()
    File "/home/kouhakuken0609/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 111, in flatten_parameters
    params = rnn.get_parameters(fn, handle, fn.weight_buf)
    File "/home/kouhakuken0609/anaconda3/envs/py36/lib/python3.6/site-packages/torch/backends/cudnn/rnn.py", line 165, in get_parameters
    assert filter_dim_a.prod() == filter_dim_a[0]
    AssertionError

Using python 3.6, PyTorch 0.3.1 and cuda80
Any tips would be appreciated. Thanks

RuntimeError while running translate.py in style_decoder

While running the English-French translation, we get a RuntimeError:

C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\Dataset.py:68: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad():instead. b = Variable(b, volatile=self.volatile) C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\Translator.py:126: UserWarning: volatile was removed and now has no effect. Usewith torch.no_grad(): instead. Variable(input, volatile=True), decStates, context, decOut) Traceback (most recent call last): File "translate.py", line 139, in <module> main() File "translate.py", line 93, in main predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch) File "C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\Translator.py", line 197, in translate pred, predScore, attn, goldScore = self.translateBatch(src, tgt) File "C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\Translator.py", line 126, in translateBatch Variable(input, volatile=True), decStates, context, decOut) File "C:\Users\chinm\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__ result = self.forward(*input, **kwargs) File "C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\Models.py", line 108, in forward output, attn = self.attn(output, context.transpose(0, 1)) File "C:\Users\chinm\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__ result = self.forward(*input, **kwargs) File "C:\Users\chinm\Downloads\DLProj\Style-Transfer-Through-Back-Translation\style_decoder\onmt\modules\GlobalAttention.py", line 49, in forward attn.data.masked_fill_(self.mask, -float('inf')) RuntimeError: expand(torch.ByteTensor{[5, 30, 43]}, size=[150, 43]): the number of sizes provided (2) must be greater or equal to the number of dimensions in the tensor (3)

What could be the cause of this error? We haven't tinkered with the code at all, other than using the Translator.py file instead of Translator_style and other stuff that was advised. We are running this on a CPU as of now though, if that matters.

We suspect this has something to do with the fact that "volatile" has been removed, as the warning says, i.e., we are using PyTorch 1.0.1 instead of PyTorch 0.3.0. Do you know of any workaround to this?

RuntimeError during translation

Hi,

I am getting the following error during style translation:

/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/modules/GlobalAttention.py:49: UserWarning: mask is not broadcastable to self, but they have the same number of elements.  Falling back to deprecated pointwise behavior.
  attn.data.masked_fill_(self.mask, -float('inf'))
/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/modules/GlobalAttention.py:50: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  attn = self.sm(attn)
/home/nikola/anaconda3/envs/env/lib/python3.5/site-packages/torch/nn/modules/container.py:67: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
  input = module(input)
Traceback (most recent call last):
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/translate.py", line 141, in <module>
    main()
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/translate.py", line 95, in main
    predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch)
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator_style.py", line 197, in translate
    src, tgt, indices = dataset[0]
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 45, in __getitem__
    align_right=False, include_lengths=True)
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 28, in _batchify
    lengths = [x.size(0) for x in data]
  File "/home/nikola/code/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 28, in <listcomp>
    lengths = [x.size(0) for x in data]
RuntimeError: invalid argument 2: dimension 0 out of range of 0D tensor at /pytorch/torch/lib/TH/generic/THTensor.c:24

I think it might be related to that one pytorch/pytorch#7982

Thanks

Sentiment Transfer Error

Running:
python translate.py -encoder_model ../models/translation/french_english/french_english.pt -decoder_model ../models/style_generators/positive_generator.pt -src ../data/sentiment/yelp/sentiment.test.0.fr -output neg_pos.txt -replace_unk $true

Error:
Traceback (most recent call last): File "translate.py", line 139, in <module> main() File "translate.py", line 66, in main translator = onmt.Translator_style(opt) File ... /Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator_style.py", line 22, in __init__ decoder.load_state_dict(checkpoint['decoder']) File ... /Style-Transfer-Through-Back-Translation/venvs/env_backtran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 519, in load_state_dict .format(name, own_state[name].size(), param.size())) RuntimeError: While copying the parameter named word_lut.weight, whose dimensions in the model are torch.Size([9603, 300]) and whose dimensions in the checkpoint are torch.Size([9603, 100]).
Please help ...
I am using the same python and pytorch version in this repository

Translation RuntimeError

When I was running translation.py with the given model and data, a RuntimeError occurred because number of sizes is smaller than number of dimensions in the tensor.

[haotian@jaxon style_decoder]$ python translate.py -model ../models/translation/english_french/english_french.pt -src ../data/political_data/democratic_only.train.en -output ../data/political_data/democratic_only.train.fr -replace_unk $true
/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py:68: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  b = Variable(b, volatile=self.volatile)
/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator.py:126: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  Variable(input, volatile=True), decStates, context, decOut)
Traceback (most recent call last):
  File "translate.py", line 139, in <module>
    main()
  File "translate.py", line 93, in main
    predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator.py", line 197, in translate
    pred, predScore, attn, goldScore = self.translateBatch(src, tgt)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator.py", line 126, in translateBatch
    Variable(input, volatile=True), decStates, context, decOut)
  File "/usr/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Models.py", line 108, in forward
    output, attn = self.attn(output, context.transpose(0, 1))
  File "/usr/lib/python3.7/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/modules/GlobalAttention.py", line 49, in forward
    attn.data.masked_fill_(self.mask, -float('inf'))
RuntimeError: expand(torch.ByteTensor{[5, 30, 43]}, size=[150, 43]): the number of sizes provided (2) must be greater or equal to the number of dimensions in the tensor (3)

Preprocessing pipelines for translation models

Hi, thank you for developing and releasing the model for wider usage.

I'm trying to apply your model to my task, and I'm just wondering what kinds of preprocessing techniques were applied to the input of your translation models. What kinds of tokenizers were used, and how were named entities handled?

Thanks in advance.

type error

when I was running the script:
python translate.py -model ../models/translation/english_french/english_french.pt -src ../data/political_data/democratic_only.train.en -output ../data/political_data/democratic_only.train.fr -replace_unk $true
in style_decoder/example.sh , I always meet an error:
image

About translation models

Hi, I have several questions about translation models.
I was trying to test your pre-trained En-Fr and Fr-En translation models to check their quality on BLEU
and I found that command like "python translate.py -model xxx.pt" only worked on En-Fr but failed on Fr-En.
I got error message like this.

Traceback (most recent call last):
File "translate.py", line 139, in
main()
File "translate.py", line 65, in main
translator = onmt.Translator(opt)
File "/home/kouhakuken0609/yasasi/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator.py", line 26, in init
model.load_state_dict(checkpoint['model'])
KeyError: 'model'

I guess it's because the Fr-En only contains parameters of encoder layers, am I right?
BTW are your BLEU scores of translation model reported on newstests2015?

I also want to replace your pre-trained translation models with ones of other language pairs to do some tests.
Any advice and suggestions will be greatly appreciated.

Error training a new classifier

Hi, I'm trying to train a new CNN classifier, but getting the following exception:

Namespace(batch_size=40, curriculum=False, data='data.pt', dropout=0.2, epochs=13, extra_shuffle=False, filter_size=5, gpus=[3], learning_rate=1.0, learning_rate_decay=0.5, log_interval=50, max_generator_batches=32, max_grad_norm=5, num_classes=2, num_filters=100, optim='sgd', param_init=0.1, pre_word_vecs_enc=None, save_model='cnn', sequence_length=50, start_decay_at=8, start_epoch=1, train_from='', train_from_state_dict='', word_vec_size=300)
Loading data from 'wiki-simple-cnn.train.pt'

  • vocabulary size. source = 50004;
  • number of training sentences. 1889378
  • maximum batch size. 40
    Building model...
  • number of parameters: 15151401

/home/nikola/anaconda3/envs/env/lib/python3.5/site-packages/torch/nn/functional.py:1168: UserWarning: Using a target size (torch.Size([40])) that is different to the input size (torch.Size([400])) is deprecated. Please ensure they have the same size.
"Please ensure they have the same size.".format(target.size(), input.size()))
Traceback (most recent call last):
File "/home/nikola/PhD/code/back-translation-copy/classifier/cnn_train.py", line 342, in
main()
File "/home/nikola/PhD/code/back-translation-copy/classifier/cnn_train.py", line 339, in main
trainModel(model, trainData, validData, dataset, optim)
File "/home/nikola/PhD/code/back-translation-copy/classifier/cnn_train.py", line 240, in trainModel
train_loss, train_acc = trainEpoch(epoch)
File "/home/nikola/PhD/code/back-translation-copy/classifier/cnn_train.py", line 210, in trainEpoch
outputs, targets, model, criterion)
File "/home/nikola/PhD/code/back-translation-copy/classifier/cnn_train.py", line 125, in memoryEfficientLoss
loss_t = crit(outputs.squeeze(-1), targets[0].float())
File "/home/nikola/anaconda3/envs/env/lib/python3.5/site-packages/torch/nn/modules/module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "/home/nikola/anaconda3/envs/env/lib/python3.5/site-packages/torch/nn/modules/loss.py", line 372, in forward
size_average=self.size_average)
File "/home/nikola/anaconda3/envs/env/lib/python3.5/site-packages/torch/nn/functional.py", line 1171, in binary_cross_entropy
"!= input nelement ({})".format(target.nelement(), input.nelement()))
ValueError: Target and input must have the same number of elements. target nelement (40) != input nelement (400)

Using python 3.5 and PyTorch 0.3.0. Any tips would be appreciated. Thanks

Translation with style, dimension 0 out of range of 0D tensor

Hi,

I ran into an issue in the final translation with style step. I added "-with_style" flag to indicate onmt.Translator_style is used instead of onmt.Translator. Encoder models and decoder models were both downloaded from the websites mentioned in Readme. Currently running python 3.6.6, pytorch 0.3.0. Translation of texts from English to French, proprocessing and train_decoder all worked fine.

[haotian@jaxon style_decoder]$ python translate.py -with_style -encoder_model ../models/translation/french_english/french_english.pt -decoder_model ../models/style_generators/democratic_generator.pt -src ../data/political_data/test.fr -output trained_models/republican_democratic.txt -replace_unk $true
Traceback (most recent call last):
  File "translate.py", line 142, in <module>
    main()
  File "translate.py", line 96, in main
    predBatch, predScore, goldScore = translator.translate(srcBatch, tgtBatch)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Translator_style.py", line 197, in translate
    src, tgt, indices = dataset[0]
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 45, in __getitem__
    align_right=False, include_lengths=True)
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 28, in _batchify
    lengths = [x.size(0) for x in data]
  File "/home/haotian/Desktop/Polarization Lab/Style-Transfer-Through-Back-Translation/style_decoder/onmt/Dataset.py", line 28, in <listcomp>
    lengths = [x.size(0) for x in data]
RuntimeError: invalid argument 2: dimension 0 out of range of 0D tensor at /opt/conda/conda-bld/pytorch_1512386481460/work/torch/lib/TH/generic/THTensor.c:24

Not able to translate(no style transfer, only translation)

I am following your example.sh
I want to generate republican_only.test.fr from the republican_only.test.en

so if I am running the below command,
python translate.py -model ../models/translation/english_french/english_french.pt -src ../data/political_data/democratic_only.train.en -output ../data/political_data/democratic_only.train.fr -replace_unk $true

I am getting the below error,
translate.py: error: the following arguments are required: -encoder_model, -decoder_model

so i guess -encoder_model will be (-model ../models/translation/english_french/english_french.pt) but what will be the -decoder_model ? I cant use the style generator model here right? because I just simply want to I want to generate republican_only.test.fr from the republican_only.test.en at first without style transfer. Please help.

Problem while running the example.sh file in style_decoder/

Hey!

I was going through your paper link and trying to set-up the code pipeline.
While running the commands written in your 'example.sh' file in style_decoder/ , I found the following error -

 usage: translate.py [-h] -encoder_model ENCODER_MODEL -decoder_model
                    DECODER_MODEL -src SRC [-tgt TGT] [-output OUTPUT]
                    [-beam_size BEAM_SIZE] [-batch_size BATCH_SIZE]
                    [-max_sent_length MAX_SENT_LENGTH] [-replace_unk]
                    [-verbose] [-n_best N_BEST] [-gpu GPU]
translate.py: error: the following arguments are required: -encoder_model, -decoder_model

However, using encoder and decoder models isn't mentioned in the README.md file.

Could you kindly help me with it? Thanks a lot!

RuntimeError: While copying the parameter named word_lut.weight

If you face RuntimeError as follows when runing the fourth command in style_decoder/example.sh ( like python translate.py -encoder_model ../models/translation/french_english/french_english.pt -decoder_model ../models/style_generators/democratic_generator.pt -src ../data/political_data/republican_only.test.fr -output trained_models/republican_democratic.txt -replace_unk $true ),

you may need to update the Translator_style.py

Traceback (most recent call last):
File "translate.py", line 140, in <module> main() File "translate.py", line 66, in main translator = onmt.Translator_style(opt) File "/home/tyt/style-trans/Style-Transfer-Through-Back-Translation-master/style_decoder/onmt/Translator_style.py", line 22, in __init__ decoder.load_state_dict(checkpoint['decoder'])
File "/home/tyt/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 519, in load_state_dict .format(name, own_state[name].size(), param.size()))
RuntimeError: While copying the parameter named word_lut.weight, whose dimensions in the model are torch.Size([9603, 300]) and whose dimensions in the checkpoint are torch.Size([9603, 100]).

Am I right?

Running with Custom Data

Hey!
Great paper
Can you provide some instructions on running the experiments with custom data? Right now the classifiers etc. are downloaded and not trained is there a way to train the same classifiers etc. on custom data?

cross-aligned auto-encoder(CAE) results

Hello!
In your paper you compare the accuracies of sentences generated by your method and CAE. And it seems that CAE is outperforming your model in Gender transformation. I tried to train CAE myself, but my results for CAE were different than in your paper. Did you use the default parameters to train CAE? If not, what did you change? Sorry for bothering, and any response would be greatly appreciated.

How does label0 or label1 matter for testing the style accuracy?

So we translated the French republican test set using the democratic decoder/generator and ran this output through cnn_translate. We gave the target as "democratic" and the labels as label0 = republican and label1 = democratic. My question is, should label1 specifically be the target? If I did the analogous experiment for republican output, would I need to give the label1 as republican (with target being republican) and label0 as democratic?

line mismatch in final translation step due to blank lines

Hi there again, I went through the process of using my own corpora to create a style generator. For the most part everything went well, using the example script files you already provided, and the information you told me about commenting/uncommenting in some previous issues. There were some issues with directories and passing information between the classifier and the style_decoder but nothing major.

However, when I run the final step in example.sh in style_decoder, similarly to #3 I got a file not found error. When I generated this file via translate.py (call it style2_only.test.fr), and tried running it, I got an error about 0D tensors and found that the generated style2_only.test.fr indeed had blank lines. If I remove them, then I can generate the translation file, let's call it style2_style1.txt. This should contain the elements of style2 translated to style1. However, this removes nice matching: a line number in style2_only.test.en no longer corresponds to the same line in style2_only.test.fr and hence makes it difficult to map translations found in style2_style1.txt back to style2_only.test.en.

Hence, how can I match the output with the original input? If the translation is blank, should I delete the line from both files?

Thanks

Error when changing datasets using pre-trained models

I met a error when I tried to run style_decoder/example.sh . I changed democratic style generator to positive style generator, and downloaded all the models I need. But I used another dataset, and there was an error:
Traceback (most recent call last): File "translate.py", line 140, in <module> main() File "translate.py", line 66, in main translator = onmt.Translator_style(opt) File "/home/tyt/style-trans/Style-Transfer-Through-Back-Translation-master/style_decoder/onmt/Translator_style.py", line 22, in __init__ decoder.load_state_dict(checkpoint['decoder']) File "/home/tyt/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 519, in load_state_dict .format(name, own_state[name].size(), param.size())) RuntimeError: While copying the parameter named word_lut.weight, whose dimensions in the model are torch.Size([9603, 300]) and whose dimensions in the checkpoint are torch.Size([9603, 100]).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.