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

Raises an error instead of a warning when is True, but we supply no … #187

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions baal/active/dataset/pytorch_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def label(self, index: Union[list, int], value: Optional[Any] = None) -> None:
to the underlying dataset is done.

Raises:
ValueError if the indices do not match the values.
ValueError if the indices do not match the values or
if no `value` is provided and `can_label` is True.
"""
if isinstance(index, int):
# We were provided only the index, we make a list.
Expand All @@ -165,13 +166,11 @@ def label(self, index: Union[list, int], value: Optional[Any] = None) -> None:
self._dataset.label(idx, val)
self.labelled_map[idx] = active_step
elif self.can_label and val is None:
warnings.warn(
raise ValueError(
"""The dataset is able to label data, but no label was provided.
The dataset will be unchanged from this action!
If this is a research setting, please set the
`ActiveLearningDataset.can_label` to `False`.
""",
UserWarning,
"""
)
else:
# Regular research usecase.
Expand Down
11 changes: 6 additions & 5 deletions notebooks/compatibility/nlp_classification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"\n",
"tokenizer = BertTokenizer.from_pretrained(pretrained_model_name_or_path=pretrained_weights)\n",
"active_set = active_huggingface_dataset(raw_train_set, tokenizer)\n",
"active_set.can_label = False # Need to manually do this for research\n",
"\n",
"# lets randomly label 100 samples, therefore len(active_set) should be 100\n",
"active_set.label_randomly(100)\n",
Expand Down Expand Up @@ -199,7 +200,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[93-MainThread ] [baal.transformers_trainer_wrapper:predict_on_dataset_generator:61] 2021-03-08T20:15:36.980534Z [\u001B[32minfo ] Start Predict dataset=67249\n"
"[93-MainThread ] [baal.transformers_trainer_wrapper:predict_on_dataset_generator:61] 2021-03-08T20:15:36.980534Z [\u001b[32minfo ] Start Predict dataset=67249\n"
]
},
{
Expand Down Expand Up @@ -393,7 +394,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[93-MainThread ] [baal.transformers_trainer_wrapper:predict_on_dataset_generator:61] 2021-03-08T20:28:15.903378Z [\u001B[32minfo ] Start Predict dataset=67239\n"
"[93-MainThread ] [baal.transformers_trainer_wrapper:predict_on_dataset_generator:61] 2021-03-08T20:28:15.903378Z [\u001b[32minfo ] Start Predict dataset=67239\n"
]
},
{
Expand Down Expand Up @@ -600,7 +601,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -614,9 +615,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
65 changes: 34 additions & 31 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
cached-property==1.5.2; python_version < "3.8" and python_version >= "3.7"
colorama==0.4.4; python_version >= "2.7" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and platform_system == "Windows"
cycler==0.11.0; python_version >= "3.7"
fonttools==4.28.2; python_version >= "3.7"
fonttools==4.28.5; python_version >= "3.7"
h5py==3.6.0; python_version >= "3.7"
joblib==1.1.0; python_version >= "3.6"
joblib==1.1.0; python_version >= "3.7"
kiwisolver==1.3.2; python_version >= "3.7"
matplotlib==3.5.0; python_version >= "3.7"
numpy==1.21.4; python_version >= "3.7" and python_version < "3.11"
matplotlib==3.5.1; python_version >= "3.7"
numpy==1.21.5; python_version >= "3.7" and python_version < "3.11"
packaging==21.3; python_version >= "3.7"
pillow==8.4.0; python_version >= "3.6"
pillow==9.0.0; python_version >= "3.7"
pyparsing==3.0.6; python_version >= "3.7"
python-dateutil==2.8.2; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
scikit-learn==0.24.2; python_version >= "3.6"
scikit-learn==1.0.2; python_version >= "3.7"
scipy==1.7.3; python_version >= "3.7" and python_version < "3.11"
setuptools-scm==6.3.2; python_version >= "3.7"
six==1.16.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
structlog==21.4.0; python_version >= "3.6"
threadpoolctl==3.0.0; python_version >= "3.6"
tomli==1.2.2; python_version >= "3.7"
torch==1.10.0; python_full_version >= "3.6.2"
torchvision==0.11.1
structlog==21.5.0; python_version >= "3.6"
threadpoolctl==3.0.0; python_version >= "3.7"
tomli==1.2.3; python_version >= "3.7"
torch==1.10.1; python_full_version >= "3.6.2"
torchvision==0.11.2
tqdm==4.62.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
typing-extensions==4.0.1; python_version >= "3.6" and python_full_version >= "3.6.2" and python_version < "3.8"
Loading