-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix transformers eval batchsize failure (#50)
* add albert test * add test * add data * fix * modified: fail.json * refactor * modified: fail.json
- Loading branch information
Showing
10 changed files
with
75 additions
and
13 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
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
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
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 @@ | ||
!fail.json |
Empty file.
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 @@ | ||
[["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}], ["a", {}]] |
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,39 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import pytest | ||
import torch | ||
|
||
from camphr.lang.torch import TorchLanguage | ||
from camphr.models import create_model | ||
from camphr.ner_labels.labels_ene import ALL_LABELS | ||
|
||
|
||
@pytest.fixture | ||
def nlp(): | ||
name = "albert-base-v2" | ||
config = f""" | ||
lang: | ||
name: en | ||
optimizer: | ||
class: torch.optim.SGD | ||
params: | ||
lr: 0.01 | ||
pipeline: | ||
transformers_model: | ||
trf_name_or_path: {name} | ||
transformers_ner: | ||
labels: {ALL_LABELS} | ||
""" | ||
return create_model(config) | ||
|
||
|
||
@pytest.fixture | ||
def data(): | ||
return json.loads((Path(__file__).parent / "fail.json").read_text()) | ||
|
||
|
||
def test(nlp: TorchLanguage, data): | ||
if torch.cuda.is_available(): | ||
nlp.to(torch.device("cuda")) | ||
nlp.evaluate(data, batch_size=256) |
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