Comments (13)
I will try to give you a demo recently.
from tener.
I will try to give you a demo recently.
i waiting for you
thank you so much
from tener.
Hello,
First and foremost I hope this email finds you well. I need to test this model. Can you please send this to me as well? The input type is str. It is really important to me.
from tener.
Sorry, since the last issue has been closed, I forgot to give the demo later.
code to add in the training file: https://github.com/fastnlp/TENER/blob/master/train_tener_en.py
# before this line https://github.com/fastnlp/TENER/blob/d2614d509dffb9b30636e3523a2f8f0dc4876708/train_tener_en.py#L101 add the following code to save the vocabulary for later usage
data_bundle.get_vocab('chars').save('/path/to/save/vocab.txt')
data_bundle.get_vocab('target').save('/path/to/save/target.txt')
# change save_path=None in https://github.com/fastnlp/TENER/blob/d2614d509dffb9b30636e3523a2f8f0dc4876708/train_tener_en.py#L123 to save_path='directory/to/save/model/', this will save a model in this directory
import torch
from fastNLP import Vocabulary
model = torch.load('/path/to/your/model') # I assume you use the Trainer save_path parameter to save the model in whole, you can find a file in the directory you pointed during training and that is the saved model.
vocab = Vocabulary.load('/path/to/save/vocab.txt')
target_vocab = Vocabulary.load('/path/to/save/target_vocab.txt')
text = "China is a country".split() # I use this simple text as an example
indices = torch.LongTensor([vocab.to_index(w) for w in text]).unsqueeze(0) # change to indices, and add a batch dimension
targets = model.predict(indices) # will be of shape [1, 5]
targets = targets[0].tolist()
targets = [target_vocab.to_word(t) for t in targets] # will be like ['S-ORG', 'O', 'O', ...]
from tener.
Thank you very much for providing the Demo. I have a question: Should I train it again?
from tener.
Also how can I save my model? Because you said # I assume you use the Trainer save_path parameter to save the model in whole, otherwise, you need to initialize your model then load the weights.
from tener.
Sorry, i did not understand what do you mean by "Should I train it again ?".
For "how can i save my model ?", i assume you are asking how to save the model in pytorch, here is the refrence https://pytorch.org/docs/stable/torch.html#torch.save
from tener.
It says that I need permission when I run the code above. Also, the model.pt is a directory. Is that normal?
from tener.
Can you please send the model.pt because my model.pt is not a file but it is a folder.
from tener.
It says Permission Denied. I am using windows and I tried to launch it as administrator.
from tener.
Sorry, I didn't save my model. And sorry for the mistake I made, you need to load 'model.pt/xxxx' (xxxx is what in your directory, that is the model). I forgot that the save_path parameter in Trainer is pointing a directory to save the model (Trainer will assign a name to the saved model by timestamp).
from tener.
It gives an error:
No module named 'models'
from tener.
It seems like that you are using the model outside the folder where you trained your model, in this case, model has to been saved by parameters. Right now, fastNLP does not support save and load trained model very well (I am working on these stuff, but it may take some time to finish), therefore, if you want to save the model for later use, the only help this repo can provide right now is a reference to the implementation of the model. Sorry for the inconvenience, as long as i finish coding the fastNLP part, i will update this issue.
from tener.
Related Issues (20)
- 发现一个小bug HOT 1
- Memory out 问题 HOT 3
- Testing and predicting with TENER HOT 1
- 关于PE向量的问题,为什么要shift?以及为什么要transpose_shift?是为了计算R中的t-j吗 HOT 2
- For the unigram and bigram embedding for Chinese dataset, what if i wanna train my own set of embedding?? HOT 1
- RelativeMultiHeadAttn
- 一个关于weibo数据集的问题 HOT 2
- Can this be used on non CONLL-2003 data format? HOT 1
- 调取batch模块读取数据时出现的无限递归问题 HOT 1
- attention score计算的疑问 HOT 2
- 如何将中文数据集转为
- Significance of using 'num_embeddings' and 'origin_shift' HOT 1
- how to (1) Prepare the English dataset.? HOT 1
- How to split the msra dataset? HOT 1
- reproducing the results on the paper HOT 1
- 请问测试的代码没有吗 HOT 2
- 请教如何理解函数_transpose_shift HOT 1
- -
- 测试结果 HOT 1
- 训练结果问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tener.