forked from chunhuizhang/bilibili_vlogs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c1d502
commit 8131406
Showing
6 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
from transformers import BertTokenizer, BertModel | ||
from transformers.models.bert import BertModel | ||
import torch | ||
from torch import nn | ||
|
||
|
||
model_name = 'bert-base-uncased' | ||
|
||
tokenizer = BertTokenizer.from_pretrained(model_name) | ||
model = BertModel.from_pretrained(model_name, output_hidden_states=True) | ||
|
||
test_sent = 'this is a test sentence' | ||
|
||
model_input = tokenizer(test_sent, return_tensors='pt') | ||
|
||
|
||
model.eval() | ||
with torch.no_grad(): | ||
output = model(**model_input) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
from transformers import BertModel, BertTokenizer | ||
|
||
model_name = 'bert-base-uncased' | ||
|
||
tokenizer = BertTokenizer.from_pretrained(model_name) | ||
model = BertModel.from_pretrained(model_name) | ||
|
||
raw_sentences = ['Tom likes cats', 'Liz likes dogs'] | ||
|
||
inputs = tokenizer.encode_plus(raw_sentences[0], raw_sentences[1], return_tensors='pt') | ||
# inputs = tokenizer('Hello, my dog is cute', return_tensors='pt') | ||
model(**inputs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from flask import Flask, render_template | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def index(): | ||
return render_template('index.html') | ||
|
||
if __name__ == '__main__': | ||
app.run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
<html> | ||
hello world! | ||
</html> |