-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GAN integration #12
base: master
Are you sure you want to change the base?
GAN integration #12
Conversation
Writing-editing network/main.py
Outdated
@@ -183,7 +192,8 @@ def train_generator(input_variable, input_lengths, target_variable, topics, mode | |||
# this is not the eval mode. | |||
if not is_eval: | |||
""" Call Discriminator, Critic and get the ReINFORCE Loss Term""" | |||
reinforce_loss = None | |||
est_values = critic_model(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the input expected here ?
Writing-editing network/main.py
Outdated
@@ -183,7 +192,8 @@ def train_generator(input_variable, input_lengths, target_variable, topics, mode | |||
# this is not the eval mode. | |||
if not is_eval: | |||
""" Call Discriminator, Critic and get the ReINFORCE Loss Term""" | |||
reinforce_loss = None | |||
est_values = critic_model(input) | |||
reinforce_loss = reinforce(gen_log, dis_out, est_values, seq_length, CommonConfig()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gen_log
is I think the generator's log probabilities. What is dis_out
? If it is the output of the discriminator, then I cannot see a call to the discriminator here that would get the output. Please add that.
Yes, it is the discriminator s output, can you just add the call and try. I
am out now. I'll go back and work on anything required
…On Sun, Jul 8, 2018, 10:34 PM Sachin Malhotra ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Writing-editing network/main.py
<#12 (comment)>
:
> @@ -183,7 +192,8 @@ def train_generator(input_variable, input_lengths, target_variable, topics, mode
# this is not the eval mode.
if not is_eval:
""" Call Discriminator, Critic and get the ReINFORCE Loss Term"""
- reinforce_loss = None
+ est_values = critic_model(input)
+ reinforce_loss = reinforce(gen_log, dis_out, est_values, seq_length, CommonConfig())
gen_log is I think the generator's log probabilities. What is dis_out? If
it is the output of the discriminator, then I cannot see a call to the
discriminator here that would get the output. Please add that.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#12 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQgbpnBLCs-slXNKwflKv3Fiq0EbtM4lks5uEutwgaJpZM4VB3jH>
.
|
…onfig arguments and run
@shruthi0898 |
Okay. I am on my way to the lab. l'll change that into batch_size and push
again.
…On Mon, Jul 9, 2018, 11:37 AM Sachin Malhotra ***@***.***> wrote:
[image: screen shot 2018-07-09 at 11 34 48 am]
<https://user-images.githubusercontent.com/11422365/42469327-3babb3ea-836c-11e8-9de8-e157437907bc.png>
That's the error I see. Mostly it is because of the wrong usage of batch
size. I can see in the critic code that you have hardcoded the value 2 in
certain dimensions. It should be batch_size there. Look into that and try
running. A successful run would give you Generator Trained successfully
for now and the model would exit. Once that is done we can test the
discriminator's training.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQgbpp_eHoso2KVYd4F8nSBsQUsW4s3zks5uE6LwgaJpZM4VB3jH>
.
|
output = output.squeeze(2) | ||
return output, hidden | ||
|
||
def decoder_train(input_tensor, encoder_hidden, decoder, seq_length): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine this with the DecoderRNN
's forward
function. These shouldn't be separate ideally. Also, try and get rid of the explicit for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shruthi0898 , the decoder_train
function shouldn't be a separate one. You should just call the DecoderRNN
's forward
function.
return output, hidden | ||
|
||
def decoder_train(input_tensor, encoder_hidden, decoder, seq_length): | ||
decoder_input = torch.zeros((2,1), dtype=torch.long) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the 2
here ?
self.hidden2tag = nn.Linear(hidden_dim, 1) | ||
self.hidden = self.init_hidden() | ||
|
||
def init_hidden(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these 2
s seem to be hardcodings. Take batch size as input and replace that in the code.
self.batch_size = batch_size | ||
|
||
def forward(self, input, hidden): | ||
output = self.embeddingF(input).view(self.batch_size, 1, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no variable as embeddingF
in your code.
Hey. Didn't understand. Which one should I try and combine? And can you
tell me when you are free to call?
…On Mon, Jul 9, 2018, 11:55 AM Sachin Malhotra ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Writing-editing network/seq2seq/discriminator.py
<#12 (comment)>
:
> + self.embedding_size = embedding_size
+
+ self.embedding = nn.Embedding(vocab_size, embedding_size)
+ self.lstm = nn.LSTM(embedding_size, hidden_size, batch_first=True)
+ self.out = nn.Linear(hidden_size, output_size)
+ self.batch_size = batch_size
+
+ def forward(self, input, hidden):
+ output = self.embeddingF(input).view(self.batch_size, 1, -1)
+ output = F.relu(output)
+ output, hidden = self.lstm(output, hidden)
+ output = self.out((output.view(self.batch_size, 1, -1)))
+ output = output.squeeze(2)
+ return output, hidden
+
+def decoder_train(input_tensor, encoder_hidden, decoder, seq_length):
Combine this with the DecoderRNN's forward function. These shouldn't be
separate ideally. Also, try and get rid of the explicit for loop.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQgbpipATKip4TMdrc1jVXsiIyYLcspFks5uE6cWgaJpZM4VB3jH>
.
|
1. Optimizer takes in generator's parameters. We need a single optimizer for both the discriminator and the generator. 2. Reinforce returns a tuple 3. Critic returns a tuple 4. Hidden and cell states should be reinitialized on every run of critic, encoder and decoder and not just once during object initialization. 5. Model not working on CUDA, working fine on CPU. Hidden states need to be .cuda() as well. That was an issue. Fixed now.
@shruthi0898 , please look into the latest commit. There were some bugs that I fixed in your code. I have mentioned the description in the commit itself. Please verify those changes. |
@shruthi0898 , Also, I have pushed the data as a separate commit in this PR. Pulling the latest changes should give you the dataset. |
Writing-editing network/main.py
Outdated
def train_discriminator(input_variable, target_variable, is_eval=False): | ||
sequence_length = input_variable.shape[1] | ||
'''add other return values''' | ||
dis_out, dis_sig = discrim_model(input_variable, sequence_length, config.batch_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong dimensions are coming here. Kindly check. The dimensions of dis_out
and target_variable
should match. The target variable has a dimensionality of (20, 1)
@shruthi0898 |
Steps to run the code:-
@shruthi0898 @ayushjaiswal
Writing-editing-Network
foldergit fetch origin && git reset --hard origin/pr/12
conda
writing-editing-network virtual environment.python Writing-editing\ network/main.py --cuda --mode 0 --conf random
The sizes of
log probabilities
,discriminator input
and thesequence length
are being printed. So the generator is providing the correct input.A successful run would give
Generator Trained successfully