Code Monkey home page Code Monkey logo

batchbald_redux's Issues

Question: (active) training loop

Hi @BlackHC,

Thanks a lot for creating this amazing library. I have a question regarding the (active) training loop in the example here:

At the end of each iteration in the while loop we acquire the new data via

active_learning_data.acquire(candidate_batch.indices)

That is, the active_learning_data.training_dataset will have new instances. Here it comes my doubt,

how the acquired instances are then included in the train_loader?

The train_loader is defined outside the while loop and does not change throughout training. It seems to me that the model sees always the same data in the training loop

# Train
for data, target in tqdm(train_loader, desc="Training", leave=False):
    data = data.to(device=device)
    target = target.to(device=device)
     ...

Shouldn't it be able to train on the "new" (extended) training set, i.e. shouldn't the train_loader be redefined at each iteration?

To provide a bit of context: I am trying to write a model leveraging both batchbald_redux and baal. Out of curiosity, can you comment on the differences between the two libraries and why you chose to reimplement some things (e.g., the ActiveLearningData?). I am trying to combine them and get the best of each one. Also, I have seen that they included an implementation of BatchBald taken from the code you provided originally with the paper, is there an advantage on using that implementation vs this one? - Well, I guess these are a bonus questions, feel free to ignore :)

Thanks a lot in advance for your attention.

Best,
Pietro

Unsure whether the behavior is expected

Hi,
I am inspecting the fields of application of BatchBald. I am using the get_batchbald_batch function from https://github.com/BlackHC/batchbald_redux/blob/master/01_batchbald.ipynb

Here is an example: we have 3 samples with 2 mc inferences for each with 4 classes. The first two examples are totally identical, while the third is completely different yet has slightly lower BALD score (due to smaller fluctuation of probabilities across mc runs):

log_probs_N_K_C = torch.Tensor([
[[0.1, 0.2, 0.3, 0.4], [0.15, 0.15, 0.3, 0.4]],
[[0.1, 0.2, 0.3, 0.4], [0.15, 0.15, 0.3, 0.4]],
[[0.4, 0.3, 0.2, 0.1], [0.4, 0.3, 0.16, 0.14]],
]).log()

I hoped BatchBald would be useful in such a case since it queries diverse instances for the batch. Yet, it queries two duplicate examples:

get_batchbald_batch(log_probs_N_K_C, batch_size=2, num_samples=3) outputs [0, 1].

I wonder whether this is the expected behavior of the algorithm or some bugs in the code may be present.
Thank you for your attention!

Redundant line of code

Hey! Awesome piece of work. I've just been going through the code and I'm curious what these two statements are for

shared_conditinal_entropies = conditional_entropies_N[candidate_indices].sum()

scores_N -= conditional_entropies_N + shared_conditinal_entropies

It seems to me as if they won't actually change which candidate is selected as the maximum, as it's adding a float to all elements of the vector scores_N

Change prob to log_prob

Even though the name makes it obvious that probabilities are expected by most functions, it would be better to change the API to use log probabilities.

This would mean that log_softmax outputs can be passed directly without having to call .exp_().

It's too easy to forget that and leads to NaN that take time to debug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.