Comments (6)
Hello,
Would your class Data
have a field named label
?
This is definitely a bug on our side, we should check that self._dataset.label
is a Callable
.
Thank you for raising this issue.
I'll explain the behavior here for other users and I would add this to our FAQ as well.
In Baal, we allow both a research mode and a production mode.
- Research mode
- Assume that you already have the labels, so we ignore the
value
even if it is not None.
- Assume that you already have the labels, so we ignore the
- Production mode
- To label something, we assume that the inner dataset has a method named
label
and we forward the value to it.
- To label something, we assume that the inner dataset has a method named
We do have a tutorial on how to use Baal in Production. It uses our class FileDataset
which does have a label
method.
https://baal.readthedocs.io/en/latest/notebooks/baal_prod_cls.html
Thanks again for reporting this issue!
from baal.
Oh,sorry.I forgot to copy the class Data
above.Thank you for your advice.This is the original class Data
:
class Data(Dataset):
def __init__(self, feature, label=None):
self.feature = feature
self.label = label
def __getitem__(self, index):
if self.label:
return self.feature[index], self.label[index]
else:
return self.feature[index]
def __len__(self):
return len(self.feature)
However I'm still confused about how to make the class Data
have a field named label
?Does you mean that I should define a label
method for the unlabelled data to query the label?
class Data(Dataset):
def __init__(self, feature):
self.feature = feature
def __getitem__(self, index):
return self.feature[index]
def __len__(self):
return len(self.feature)
def label(self, index):
return self.feature[index].sum()
when I use pool.label(index=4)
,it still has a problem:
c:\users\anaconda3\lib\site-packages\baal\active\dataset.py:170: UserWarning: 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)
Could you give me an example?Thank you very much.
from baal.
yes a label
method sorry.
The warning you see is normal. If it gets too verbose, we should suppress it.
If the labels are already available then you don't need this method.
But in the case of a live application you would get something like this:
# Some definitions
your_heuristic = BALD()
pool = active_dataset.pool
your_predictions = ModelWrapper.predict_on_dataset(pool, ...)
# The shape of `your_predictions` is [len(pool), n_classes, ..., iterations]
# Get the next batch of samples to label. Note: These indices are according to the pool.
ranks = your_heuristic(your_predictions)
# Now let's ask a human to label those samples.
labels = ask_a_human(ranks, pool)
# To edit the dataset labels, you can now add those labels to your dataset. Still, the indices are according to the pool.
active_dataset.label(ranks, labels)
See how we make the label
method in FileDataset
here
from baal.
If you don't know the label, you should just return a dummy value for the labels.
I would propose something like this:
class Data(Dataset):
def __init__(self, feature, label=None):
self.feature = feature
self.lbl = label or [-1] * len(feature)
def __getitem__(self, index):
return self.feature[index], self.lbl[index]
def __len__(self):
return len(self.feature)
def label(self, index, value):
self.lbl[index] = value
from baal.
I'm currently working on our FAQ. here is a section that I would like to add on the split. If there is something missing, please let me know and I'll add it.
How can I specify that a label is missing and how to label it.
The source of truth for what is labelled is the ActiveLearningDataset._labelled
array.
This means that we will never train on a sample if it is not labelled according to this array.
This array determines the split between the labelled and unlabelled datasets.
# Let ds = D, the entire dataset with labelled/unlabelled data.
ds = YourDataset()
al_dataset = ActiveLearningDataset(ds, ...)
# For convenience, let's label 10 samples at random.
# But you can provide the `labelled` array to ActiveLearningDataset
# if you already have labels.
al_dataset.label_randomly(10)
pool = al_dataset.pool
From a rigorous point of view:
Then, we train our model on
Let a method query_human
performs the annotations, we can label our dataset using indices relative to YourDataset
has a method named label
which has the following definition: def label(self, idx, value)
where we give the label for indice idx
. There the indice is not relative to the pool, so you don't have to worry about it.
from baal.
That's very clear.Thank you very much.
from baal.
Related Issues (20)
- Add EPIG HOT 8
- Support for early stopping in `ModelWrapper.train_on_dataset()` HOT 1
- How we can use Baal for NER using huggingface HOT 5
- `train_on_dataset` much slower when using `ActiveLearningDataset` compared to torch `Dataset` HOT 6
- Argument in `test_on_dataset` and `train_and_test_on_datasets` functions to write "val_" metrics instead of "test_" HOT 2
- MCCachingModule and `replicate_in_memory=False` HOT 2
- torchmetrics Accuracy() fails if `get_metrics()` is called before `test_on_dataset` HOT 2
- Pool predictions also done for "random" heuristic HOT 1
- Different Loss Functions HOT 1
- HF transformer: evaluate() performs one sample with MC Dropout HOT 4
- Baal seems to ignore eval_batch_size causing gpu memory issues HOT 6
- Question - Using BAAL for automatic speech recognition (speech to text) HOT 7
- Structlog log.warnings() error HOT 2
- Add self-training option HOT 2
- [Baal 2.0] All in one Experiment Object
- Training Args for ModelWrapper
- Rework QuickStart documentation HOT 3
- Documentation for Criterion HOT 1
- Deprecate the old stuff (ActiveLearningLoop, ModelWrapper args) HOT 1
- Issue with get_metrics() HOT 3
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 baal.