kaituoxu / x-punctuator Goto Github PK
View Code? Open in Web Editor NEWA PyTorch implementation of a punctuation prediction system using (B)LSTM, which automatically adds suitable punctuation into text without punctuation.
A PyTorch implementation of a punctuation prediction system using (B)LSTM, which automatically adds suitable punctuation into text without punctuation.
中文数据集是如何处理的呢,我看到有一个vocab文件,这个是把数据集全部转为了分词结果还是额外的处理,比如词向量
Namespace(batch_size=5, bidirectional=1, checkpoint=0, continue_from='', early_stop=0, embedding_dim=256, epochs=30, half_lr=0, hidden_size=512, l2=0.0, lr=0.001, max_norm=5, model_path='final.pth.tar', num_class=5, num_embeddings=5002, num_layers=2, num_workers=1, print_freq=1, punc_vocab='data/punc_vocab', save_folder='exp/temp', train_data='data/train20', use_cuda=0, valid_data='data/train20', visdom=0, visdom_epoch=0, visdom_id='X-Punctuator training', vocab='data/vocab')
LstmPunctuator(
(embedding): Embedding(5002, 256)
(lstm): LSTM(256, 512, num_layers=2, batch_first=True, bidirectional=1)
(fc): Linear(in_features=1024, out_features=5, bias=True)
)
Number of parameters: 10739205
Training...
Traceback (most recent call last):
File "/pkwork2/xhs92/task1.2/X-Punctuator/egs/toy/../../src/bin/train.py", line 84, in
main(args)
File "/pkwork2/xhs92/task1.2/X-Punctuator/egs/toy/../../src/bin/train.py", line 78, in main
solver.train()
File "/pkwork2/xhs92/task1.2/X-Punctuator/src/solver/solver.py", line 77, in train
tr_avg_loss = self._run_one_epoch(epoch)
File "/pkwork2/xhs92/task1.2/X-Punctuator/src/solver/solver.py", line 181, in _run_one_epoch
pred = self.model(padded_input, input_lengths)
File "/restools/tools/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/pkwork2/xhs92/task1.2/X-Punctuator/src/model/model.py", line 43, in forward
packed_output, _ = self.lstm(packed_input)
File "/restools/tools/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/restools/tools/anaconda3/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 182, in forward
self.num_layers, self.dropout, self.training, self.bidirectional)
TypeError: lstm() received an invalid combination of arguments - got (Tensor, Tensor, tuple, list, bool, int, int, bool, int), but expected one of:
Hi, I was trying to run your toy example script (run.sh) on windows bash and I received the following error. I have tried just train.py with the same arguments with the same error. I'm using PyTorch 1.2 so was wondering if its due to compatibility issue with 0.4. Thanks.
Traceback (most recent call last):
File "C:/Users/tsd/Desktop/Python_Projects/DSL/Repositories/X-Punctuator/egs/toy/../../src/bin/train.py", line 84, in
main(args)
File "C:/Users/tsd/Desktop/Python_Projects/DSL/Repositories/X-Punctuator/egs/toy/../../src/bin/train.py", line 78, in main
solver.train()
File "C:\Users\tsd\Desktop\Python_Projects\DSL\Repositories\X-Punctuator\src\solver\solver.py", line 77, in train
tr_avg_loss = self._run_one_epoch(epoch)
File "C:\Users\tsd\Desktop\Python_Projects\DSL\Repositories\X-Punctuator\src\solver\solver.py", line 181, in _run_one_epoch
pred = self.model(padded_input, input_lengths)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "C:\Users\tsd\Desktop\Python_Projects\DSL\Repositories\X-Punctuator\src\model\model.py", line 43, in forward
packed_output, _ = self.lstm(packed_input)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 562, in forward
return self.forward_packed(input, hx)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 554, in forward_packed
output, hidden = self.forward_impl(input, hx, batch_sizes, max_batch_size, sorted_indices)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\rnn.py", line 529, in forward_impl
self.num_layers, self.dropout, self.training, self.bidirectional)
TypeError: lstm() received an invalid combination of arguments - got (Tensor, Tensor, tuple, list, bool, int, float, bool, int), but expected one of:
- (Tensor data, Tensor batch_sizes, tuple of Tensors hx, tuple of Tensors params, bool has_biases, int num_layers, float dropout, bool train, bool bidirectional)
didn't match because some of the arguments have invalid types: (Tensor, Tensor, !tuple!, !list!, bool, int, float, bool, !int!)- (Tensor input, tuple of Tensors hx, tuple of Tensors params, bool has_biases, int num_layers, float dropout, bool train, bool bidirectional, bool batch_first)
didn't match because some of the arguments have invalid types: (Tensor, !Tensor!, !tuple!, !list!, !bool!, int, !float!, bool, !int!)
您好,请问下,我训练自己的模型,需要自己生成vocab,还是可以直接用你的vocab文件?
Will the model not work if data is changed to match that of English?
Thanks for providing this useful implementation. I wanted to build upon it in one of my project, but found that there is no license associated to this project at the moment.
So it would be very helpful if you could add a license to this project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.