Skip to content
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

Error in rnn.py file #49

Open
SMESetty opened this issue Aug 1, 2019 · 2 comments
Open

Error in rnn.py file #49

SMESetty opened this issue Aug 1, 2019 · 2 comments

Comments

@SMESetty
Copy link

SMESetty commented Aug 1, 2019

After making a few changes in the utils.py file, as well as changing from python 2 to Python 3, I am getting an error in the rnn.py file when i try to run the train.py file. The error states- "TypeError: super(type, obj): obj must be an instance or subtype of type". I changed "super(LSTM, self).init('LSTM', *args, **kwargs)" to the below two lines-
self.as_super = super(LSTM, self)
self.as_super.init('LSTM', *args, **kwargs) in the def init function,
but to no avail.
Any help would be appreciated.

@Tianchen627
Copy link

I also change the code to fit Python 3.I have changed all the / operator to //,for example

        self.cond_col_name_enc = nn.LSTM(input_size=N_word, hidden_size=N_h//2,
                num_layers=N_depth, batch_first=True,
                dropout=0.3, bidirectional=True)

It works well so far,I hope it can help u.

@anshudaur
Copy link

Hi, I am still getting the error in rnn.py.
Error stacktrace is : Traceback (most recent call last):
File "test.py", line 74, in
print("Dev acc_qm: %s;\n breakdown on (agg, sel, where): %s",epoch_acc(model, BATCH_SIZE, val_sql_data, val_table_data, TEST_ENTRY))
File "D:\Thesis\Seq2SQL\SQLNet\sqlnet\utils.py", line 201, in epoch_acc
score = model.forward(q_seq, col_seq, col_num, pred_entry, gt_sel = gt_sel_seq)
File "D:\Thesis\Seq2SQL\SQLNet\sqlnet\model\sqlnet.py", line 103, in forward
agg_score = self.agg_pred(x_emb_var, x_len, col_inp_var, col_name_len, col_len, col_num, gt_sel=gt_sel)
File "C:\Users\anshu\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "D:\Thesis\Seq2SQL\SQLNet\sqlnet\model\modules\aggregator_predict.py", line 35, in forward
h_enc, _ = run_lstm(self.agg_lstm, x_emb_var, x_len)
File "D:\Thesis\Seq2SQL\SQLNet\sqlnet\model\modules\net_utils.py", line 22, in run_lstm
sort_ret_s, sort_ret_h = lstm(lstm_inp, lstm_hidden)
File "C:\Users\anshu\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "C:\Users\anshu\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 556, in forward
self.check_forward_args(input, hx, batch_sizes)
File "C:\Users\anshu\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 508, in check_forward_args
self.check_input(input, batch_sizes)
File "C:\Users\anshu\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 159, in check_input
self.input_size, input.size(-1)))
RuntimeError: input.size(-1) must be equal to input_size. Expected 300, got 100

Can you please tell me how were you able to fix the errors while converting the code to Python3.7 compatible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants