Giter Site home page Giter Site logo

baal-org / baal Goto Github PK

View Code? Open in Web Editor NEW
859.0 18.0 86.0 45.92 MB

Bayesian active learning library for research and industrial usecases.

Home Page: https://baal.readthedocs.io

License: Apache License 2.0

Dockerfile 0.30% Python 99.41% Makefile 0.29%
active-learning deep-learning machine-learning pytorch python bayesian-active-learning ai

baal's People

Contributors

arthur-thuy avatar bartvanmarrewijk avatar bresilla avatar camiwilliams avatar dependabot[bot] avatar dref360 avatar fbickfordsmith avatar georgepearse avatar janfreyberg avatar nitish1295 avatar orangetoaster avatar parmidaatg avatar rafapi avatar reeshipaul avatar thierryjudge avatar vfdev-5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baal's Issues

Please provide an example for multilayer perceptron regression too in experiments section.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Enable loading state_dicts in active learning dataset

Is your feature request related to a problem? Please describe.
We currently are able to get a state dict for ActiveLearningDataset, but not load a state dict. This should be enabled to make resuming from pre-empted states easier.

Describe the solution you'd like

A load_state_dict method that assigns the labelled value from the state dict to the object.

Describe alternatives you've considered

Adding this method to the active learning loop, instead; but this is a bit closer to where the data that is saved / loaded is relevant.

Flagged by @IssamLaradji

Can't recover original filenames after predict_on_dataset

Describe the bug
If I run the example "Use BaaL in production (Classification)" and I use top_uncertainty = heuristic(predictions)[:10] I get indices from the unlabeled pool dataset back. To recover the original filenames from train_dataset I need indices on the whole active_learning_ds otherwise already labeled data is not taken into consideration correctly.

To Reproduce
Try out the example and print heuristic(prediction)

Expected behavior
heuristic(predictions) should give back indices that refer to the active_learning_ds not only the pool.

Vesion (please complete the following information):

  • OS: Ubuntu 16.04
  • Python: 3.7
  • BaaL version: 1.1.1

Expand the user guide

  • Add more details on BaaL <--> BALD
  • We need some extra information on Bayesian Active Learning
  • Step-by-step introduction

Investigate Integration with tensorflow

Is your feature request related to a problem? Please describe.
As per conversation with @tboquet, this feature could help him working with BaaL in his research at Unity.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

num_samples should be a positive integer value, but got num_samples=0

First, I would like to know if this project works with segmentation problems, namely Unet - this one in particular.

Also, I tried to run a simple pipeline but I am getting this error when creating the dataset. However, if I run that piece of code it works:

from torch.utils.data.dataloader import default_collate
for data, target in DataLoader(train_dataset, batch_size, True, num_workers=4,
                                           collate_fn=None):
    print(data)

My Dataset constructor:

class Dataset(BaseDataset):
"""CamVid Dataset. Read images, apply augmentation and preprocessing transformations.

Args:
    images_dir (str): path to images folder
    masks_dir (str): path to segmentation masks folder
    class_values (list): values of classes to extract from segmentation mask
    augmentation (albumentations.Compose): data transfromation pipeline 
        (e.g. flip, scale, etc.)
    preprocessing (albumentations.Compose): data preprocessing 
        (e.g. noralization, shape manipulation, etc.)

"""
    def __init__(
            self, 
            ids,
            images_dir, 
            masks_dir, 
            classes=None, 
            augmentation=None, 
            preprocessing=None,
            show_original=False
    ):
        self.ids = ids#os.listdir(images_dir)
        self.images_fps = [os.path.join(images_dir, image_id) for image_id in self.ids]
        self.masks_fps = [os.path.join(masks_dir, image_id) for image_id in self.ids]
        
        # convert str names to class values on masks
        self.class_values = [i+1 for i,c in enumerate(classes)]
        
        self.augmentation = augmentation
        self.preprocessing = preprocessing
        self.show_original=show_original
    
    def __getitem__(self, i):
        try:
            # read data
            #print(self.images_fps[i])
            filename=self.images_fps[i]
            if not filename.endswith(".png"):
                # Virtual openslide patch in form filename_col_x_row_y
                slide_name=Path(filename).stem.split("_col_")[0]
                roi_x,roi_y=filename.split("col_")[1].split("_row_")
                roi_xy_large=int(int(roi_x)*patch_size),int(int(roi_y)*patch_size)
            
                slide= openslide.open_slide(slide_paths[slide_name])
                image=slide.read_region(roi_xy_large,0,(patch_size,patch_size))
                #print((roi_xy_large,0,(patch_size,patch_size)))
                #plt.imshow(img)
                #plt.show()

                image=image.convert('RGB')
                if self.show_original:
                    plt.imshow(image)
                    plt.show()
                image = np.asarray(image)
                mask=None
                
            else:
                image = cv2.imread(filename)
                

                image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
                if self.show_original:
                    plt.imshow(image)
                    plt.show()

                #print(self.masks_fps[i])
                mask = cv2.imread(self.masks_fps[i], 0)

            

            # No mask, ex: false positives
            if mask is None:
                mask= PIL.Image.new('RGB', (256, 256), (0, 0, 0))
                mask=np.array(mask.convert("L"))
                
#             if image is None:
#                 image= PIL.Image.new('RGB', (256, 256), (0, 0, 0))
#                 image=np.array(image.convert("L"))


            #print('self.images_fps[i]',self.images_fps[i])
            #print('self.masks_fps[i]',self.masks_fps[i])

            #print('self.class_values:', self.class_values)
            #print('mask.max:', np.max(mask))
            #print('mask.min:', np.min(mask))
            #print('mask.unique:', np.unique(mask))

            # extract certain classes from mask (e.g. cars)
            masks = [(mask == v) for v in self.class_values]
            mask = np.stack(masks, axis=-1).astype('float')

            # apply augmentations
            if self.augmentation:
                sample = self.augmentation(image=image, mask=mask)
                image, mask = sample['image'], sample['mask']
#                 set_trace() if DEBUG else None
                
#                 mask[np.all(image == [0, 0, 0], axis=-1)]=0

            # apply preprocessing
            if self.preprocessing:
                sample = self.preprocessing(image=image, mask=mask)
                image, mask = sample['image'], sample['mask']
                
                

            return image, mask
            
        except Exception as error:
            print("error",error,self.images_fps[i],self.masks_fps[i])
            raise

    def __len__(self):
        return len(self.ids)

Regards

Add random_state for ActiveDataSet

Experiments are always affected by label_randomly() in the beginning. This randomness would not let to have a proper setup for comparing the experiments properly.

Having a random_state added to ActiveDataset will make sure that setting this attribute, the initial randomly labelled data wouldn't change and hence different experiments could start from the same equal state. This gives a fair setup to compare heuristics/sampling techniques.

Error while running heuristics and rank

Hello, I am getting this AssertionError while running heuristics on my predictions.

AssertionError                            Traceback (most recent call last)
<ipython-input-123-eb41a8422662> in <module>
     17 
     18         if epoch % 20 == 0:
---> 19             should_continue = active_loop.step()
     20             model.reset_fcs()
     21             if not should_continue:

/code/notebooks/baal_al/active/active_loop.py in step(self)
     57             probs = self.get_probabilities(pool, **self.kwargs)
     58             if probs is not None and (isinstance(probs, types.GeneratorType) or len(probs) > 0):
---> 59                 to_label = self.heuristic(probs)
     60                 to_label = indices[np.array(to_label)]
     61                 if len(to_label) > 0:

/code/notebooks/baal_al/active/heuristics/heuristics.py in __call__(self, predictions)
    207     def __call__(self, predictions):
    208         """Rank the predictions according to their uncertainties."""
--> 209         return self.get_ranks(predictions)
    210 
    211 

/code/notebooks/baal_al/active/heuristics/heuristics.py in get_ranks(self, predictions)
    203             scores = self.get_uncertainties(predictions)
    204 
--> 205         return self.reorder_indices(scores)
    206 
    207     def __call__(self, predictions):

/code/notebooks/baal_al/active/heuristics/heuristics.py in reorder_indices(self, scores)
    180         if isinstance(scores, Sequence):
    181             scores = np.concatenate(scores)
--> 182         assert scores.ndim <= 2
    183         ranks = np.argsort(scores, -1)
    184         if self.reversed:

AssertionError: 

Any idea on what may be causing this?

Coresets for unsupervised active learning.

Is your feature request related to a problem? Please describe.
Cold-start is a real problem in active learning, we need to label randomly a few dozens labels before starting using active learning.

Describe the solution you'd like
A solution similar to Baal AbtractHeuristic.

coreset_algo = MyCoresetAlgorithm()
ranks = coreset_algo(my_dataset)
# or 
ranks = coreset_algo(predictions)

Describe alternatives you've considered
None

Support for gradually increasing the validation-set size proportional to labelled data

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

How to use the BaaL framework for named entity recognition?

I'm seeking guidance on how to use the BaaL framework for a named entity recognition NLP task. In this task, every training sample is made up of a sequence of tokens and each token has a label. So each sample has not one, but many labels. And the number of labels per sample is not fixed.

Can the BaaL framework deal with this use case? I'm asking because most places in the documentation seem to assume there is one label per training sample.

Better error message on multi-outputs

When we feed a multi-output model to BALD, the resulting error is not clear.

We should handle this error and propose a solution in the error message.

Ensemble Based Active Learning

Would this project be interested in ensemble based techniques for active learning? As seen in [1] ensembles can be an effective technique for deep active learning achieving competitive/superior performance to competing techniques (ie MC-Dropout). More generally they have been widely used in non-deep based approaches to active learning as well (see [2] chapter 3 for a review).

All of the heuristics this library has already implemented could immediately be used for ensemble predictions.

I see that SWAG is on the road map and this could be a more general feature of different ensemble style approaches (bootstrap, FGE, SWAG, diversity encouraging, etc...)

If this is something you all would like to move forward with. I would be happy to implement it. I've been working on active learning and already have my own implementations. Since finding this library I am in the midst of porting my code over to it, since I like it so much.

My only concern is that when resource constrained it is difficult to hold all of the ensemble members in memory and can be expensive to move them in and out. In my own experiments I've been generating the members of the ensemble one at a time and predicting on all data points from the pool set and validation set deleting the member and start training the new member. This might be a bit awkward given the current implementation of the ModelWrapper and ActiveLearningLoop.

Model.train()
active_loop.set()

Essentially for the above workflow to still work it would require the below line to be already executed and cached by the model and the active_loop would use the cache.

 probs = self.get_probabilities(pool, **self.kwargs)

Thanks for your time.

[1] http://openaccess.thecvf.com/content_cvpr_2018/papers/Beluch_The_Power_of_CVPR_2018_paper.pdf

[2] https://www.morganclaypool.com/doi/abs/10.2200/S00429ED1V01Y201207AIM018

BatchBALD doesnt work with more than 3 dimensions

The docstring for BatchBALD._sample_from_history shows the probs argument to be:

probs (Tensor[batch, classes, ..., iterations]): Tensor to be sampled from.

However, when using more than 3 dimensions (for example to represent different pixels in an image), the line:

probs = probs.permute(0, 2, 1)

in _draw_choices crashes because it expects exactly 3 dimenions.

A question about ActiveLearningDataset.

Hi,I want to construct my own dataset like the following:

import torch
from torch.utils.data import Dataset
from baal.active.dataset import ActiveLearningDataset

a = []
for i in range(20):
    a.append(torch.rand(10))

data = Data(a)
pool = ActiveLearningDataset(data)

and I want to label several data in the dataset:

pool.label(index=4, value=torch.tensor([0]))

But I get the error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
 in 
----> 1 pool.label(index=4, value=torch.tensor([0]))

 in label(self, index, value)
    159             if self.can_label and val is not None:
    160                 print(self._dataset.label)
--> 161                 self._dataset.label(index, val)
    162                 self._labelled[index] = 1
    163             elif self.can_label and val is None:

TypeError: 'NoneType' object is not callable

I read the original code, and find the self._dataset.label is None.Is the above code right or is this a bug?

BatchBALD implementation

It just selects a permutation of points present in the batch but not all combinations as mentioned in the paper. The number of combinations would be c^b according to the paper but according to your code it will have b or b[max_size] combinations. Am I missing anything?

Lets say there are total 100 points , 4 classes and 10 iterations
so prediction tensor would be of shape (100,4,10)

now lets say I am creating a set of points and I have 4 points in the history = [3,18,45,60]
now selected in your code would be predictions[np.random.permutation(history[:MAX_SELECTED]]
it would jusr randomly permute these indices in history and subset prediction tensor for those values. These are not combinations in my opinion. I would assume to sample combination I will need to create a tensor of size 4^5 x 10 (4 is num classes and 5 is the batch size)

https://github.com/ElementAI/baal/blob/377ea8ed1bb78936f79d2a343bfe6835668446a3/src/baal/active/heuristics/heuristics.py#L287

I looked at author's original implementation and they seem to have implemented the sampling logic as expected. (https://github.com/BlackHC/BatchBALD/blob/master/src/joint_entropy/sampling.py)

Thanks in advance!

Support ArrowDataset (for tabular data and nlp)

Is your feature request related to a problem? Please describe.
The arrowdataset doesnt support numpy indexing

Describe the solution you'd like
We would fix this by changing the pool indexing from numpy to list

Support tuple and dicts for *_on_batch

Describe the bug
If the dataset returns a Dict or Tuple, it breaks.

To Reproduce

class MyDS(Dataset):
	def __len__(self):
		return 5

	def __getitem__(self,idx):
		return (torch.randn(3, 20, 20), torch.randn(3, 20, 20)), 5
...

wrapper.train_on_batch(MyDS()[1], ...)

**Expected behavior**

The list of tensors should be acceted and `cuda` should be called on them.

**Vesion (please complete the following information):**
 - BaaL version: 1.0

Support for Pytorch Lightning

Pytorch Lightning has become increasingly popular. It would be a valuable addition to support their community.

The main component to support is the ActiveLearningLoop. We can make a new Mixin to support our ModelWrapper.predict_on_dataset, ModelWrapper.predict_on_batch and some utils like limiting the number of samples in the pool.

Random cannot be used with Map-Reduce

Describe the bug
If we use the Random heuristics with a map-reduce technique, we cannot call reorder_indices on it.

To Reproduce

from baal.active.heuristics import Random
import numpy as np
scores = [np.arange(3),
		  np.arange(3,9)]
Random().reorder_indices(scores) # Throws

Expected behavior
Should work.

Vesion (please complete the following information):

  • OS: Ubuntu
  • Python: 3,7
  • BaaL version: master

skip tests which include torchvision if the project is not vision

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

two bugs in experiments/segmentation/utils.py

Describe the bug
Two bugs in experiments/segmentation/utils.py:

  1. forgot to import torch (causing an error on line 103)
  2. index error in the self.alpha.gather function in class FocalLoss

To Reproduce
errors occur when running the unet example code:
python experiments/segmentation/unet_mcdropout_pascal.py

Some advices:

  • import torch (line 6)
  • remove line 122: at = self.alpha.gather(0, target.data.view(-1))
  • on line 122 insert: select = (target!=0).type(torch.LongTensor).cuda()
  • on line 123 insert: at = self.alpha.gather(0,select.data.view(-1))
  • thanks to this URL: clcarwin/focal_loss_pytorch#4

Expected behavior
Errors are solved, when applying the advices above. Maybe make line 122 dynamic when not using cuda.

Version (please complete the following information):

  • OS: Ubuntu 18.04
  • Python: 3.7
  • BaaL version: 1.2.1
  • CUDA: 10.1
  • cuDNN: 7.6.5
  • Pytorch: 1.7.0+cu101
  • torchvision: 0.8.1+cu101

Additional context
The alpha bug causes a CUDA or cuDNN assertion error.

Allow configurations of how "iterations" is handled by ModelWrapper to preserve memory

When running the predict_* methods of ModelWrapper, the same batch size that works during training / testing may cause out-of-memory errors because we replicate the data in each batch so the memory footprint will be e.g. 10x the memory footprint during training.

I think it may make sense to allow setting that multiple iterations of the data through the model are done in sequence (e.g. in a for-loop). This will probably (haven't tested this) be a bit slower than replicating the data but it's a speed / memory trade-off that the user could decide themselves. I am thinking this could be an argument to ModelWrapper.__init__

I think this would match user expectations (that picking a batch size that fits in memory during training will also fit during prediction).

If people agree, I can implement this with @rafapi (who ran into this issue in the first place when using a local GPU!)

FileDataset cannot be used in Research

Describe the bug
When using FileDataset in a research setting, it fails silently.

x = FileDataset(['asda'] * 10)
ds = ActiveLearningDataset(x)
ds.label_randomly(1)
# the length is still 0

Support Random target_transform in ALDataset

Is your feature request related to a problem? Please describe.
In Segmentation, we need to augment both the target and the input.
At test time, only the transform is updated.

DropConnect wrapped model could not be parallelized

Describe the bug
While using the baal.bayesian.MCDropoutConnectModule wrapper, it is impossible to train the model with multiple GPUs.
One gets the following error:

RuntimeError: Expected tensor for argument #1 'input' to have the same device as tensor for argument #2 'weight'; but device 1 does not equal 0 (while checking arguments for cudnn_convolution)

To Reproduce
Simple training with PyTorch DataParallel and at least 2 GPUs.

Expected behavior
A possible solution would be to remove the dynamic forward method re-assignment for Conv and Dense layers. This issue is described here: pytorch/pytorch#8637

Integrate Mypy

As most of the dependencies started to integrate mypy, it seems to be the nice next step to do to stay in align with our dependencies and best practices.

Make PL trainer epoch self-aware

Hopefully, ResetCallback can take care of it but need further tests.

Avoid this:

for _ in range(AL_STEP):
	trainer.current_epoch = 0
	trainer.fit()
	...

DataParrallel does not work with BaaL PL

Describe the bug
If we use multiple gpus, Trainer.get_model() returns a LightningDataParallel and we can't get pool_loader from it.

To Reproduce
Use multiple gpus with the example.

Stack trace:

Traceback (most recent call last):
  File "experiments/mc_dropout_pl/mcd_cls_experiment.py", line 224, in <module>
    main()
  File "experiments/mc_dropout_pl/mcd_cls_experiment.py", line 218, in main
    should_continue = loop.step()
  File "/opt/conda/lib/python3.7/site-packages/baal/active/active_loop.py", line 67, in step
    to_label = self.heuristic(probs)
  File "/opt/conda/lib/python3.7/site-packages/baal/active/heuristics/heuristics.py", line 209, in __call__
    return self.get_ranks(predictions)
  File "/opt/conda/lib/python3.7/site-packages/baal/active/heuristics/heuristics.py", line 592, in get_ranks
    predictions = np.array([np.ones([t.shape[0]]) for t in predictions]).reshape([-1])
  File "/opt/conda/lib/python3.7/site-packages/baal/active/heuristics/heuristics.py", line 592, in <listcomp>
    predictions = np.array([np.ones([t.shape[0]]) for t in predictions]).reshape([-1])
  File "/opt/conda/lib/python3.7/site-packages/baal/utils/pytorch_lightning.py", line 93, in predict_on_dataset_generator
    dataloader = self.model.pool_loader()
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 576, in __getattr__
    type(self).__name__, name))
AttributeError: 'LightningDataParallel' object has no attribute 'pool_loader'

Expected behavior
Should work

Vesion (please complete the following information):

  • OS:Ubuntu
  • Python: 3.7
  • BaaL version: master

Additional context
Add any other context about the problem here.

Example for ensembles with ModelWrapper.

We should have an example on how to use EnsembleModelWrapper.

Basically:

wrapper = EnsembleModelWrapper(..)
N_MODELS = 5

for _ in range(N_MODELS):
   wrapper.model.apply(reset_weight_method)
   wrapper.train_on_dataset(train_dataset, ...)
   wrapper.add_checkpoint()

# We now have 5 models when we use predict!

# The shape will be the same as MC-Dropout [batch_size, C, ..., Iterations]
predictions = wrapper.predict_on_dataset(...)

Heuristics must support Multi-outputs

Is your feature request related to a problem? Please describe.
Current heuristics do not support multi-output models. For example, SSD outputs both the location of the boxes and the classifications.

Describe the solution you'd like
A way to combine heuristics.
heuristics.combine(Variance(), BALD())

Describe alternatives you've considered
Custom heuristics or inherit ModelWrapper

Additional context
Add any other context or screenshots about the feature request here.

import torch
from torch import nn
from torch.utils.data import Dataset

from baal import ModelWrapper
from baal.active.heuristics import BALD


class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = nn.Linear(32, 3)

    def forward(self, x):
        return self.model(x), self.model(x * x)


class MyDataset(Dataset):
    def __len__(self):
        return 30

    def __getitem__(self, idx):
        return torch.randn(32), 1


model = MyModel()
dataset = MyDataset()

wrap = ModelWrapper(model, None)
bald = BALD()
predictions = wrap.predict_on_dataset(dataset, batch_size=32, iterations=10, use_cuda=False)
assert len(bald(predictions)) == len(dataset)

Blogs webpage

In Medium and on baal.readthedocs.io

We would like a Tab on the website where we can blog easily.

Implementation of BADGE

Is your feature request related to a problem? Please describe.
Badge implementation is requested by some users

Tensor type error while running the PyTorch Lightning example with CUDA

Describe the bug

Crash Log

Traceback (most recent call last):                                                                                    
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/modelwrapper.py", line 444, in mc_
inference                                                                                                             
    out = model(data)                                                                                                 
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl        
    result = self.forward(*input, **kwargs)                                                                           
  File "experiments/pl_baal_example.py", line 48, in forward                                                          
    return self.vgg16(x)     
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)                
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torchvision/models/vgg.py", line 43, in forward             
    x = self.features(x)     
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)                
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)    
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)                
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 419, in forward             
    return self._conv_forward(input, self.weight)          
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 416, in _conv_forward
    self.padding, self.dilation, self.groups)              
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same              

The above exception was the direct cause of the following exception:                                                  

Traceback (most recent call last):                         
  File "experiments/pl_baal_example.py", line 181, in <module>                                                        
    main(HParams())          
  File "experiments/pl_baal_example.py", line 175, in main                                                            
    should_continue = loop.step()                          
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/active/active_loop.py", line 67, in step                       
    to_label = self.heuristic(probs)                       
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/active/heuristics/heuristics.py", line 209, in __call__        
    return self.get_ranks(predictions)                     
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/active/heuristics/heuristics.py", line 201, in get_ranks       
    scores = self.get_uncertainties_generator(predictions)                                                            
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/active/heuristics/heuristics.py", line 142, in get_uncertainties_generator                   
    for pred in predictions:                               
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/utils/pytorch_lightning.py", line 67, in predict_on_dataset_generator                        
    pred = self.model.predict_step(data, idx)              
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/utils/pytorch_lightning.py", line 28, in predict_step          
    out = mc_inference(self, data, self.hparams.iterations, self.hparams.replicate_in_memory)                         
  File "/home/luigi/anaconda3/lib/python3.7/site-packages/baal-1.2.0-py3.7.egg/baal/modelwrapper.py", line 449, in mc_inference                    
    Note that there will be some speed trade-offs''') from e                                                          
RuntimeError: CUDA ran out of memory while BaaL tried to replicate data. See the exception above.                     
            Use `replicate_in_memory=False` in order to reduce the memory requirements.                               
            Note that there will be some speed trade-offs    

To Reproduce
Running experiments/pl_baal_example.py.

Vesion (please complete the following information):

  • OS: Manjaro
  • Python: Python 3.7
  • BaaL version: master

Update PL to 1.2.0

We first implemented our PL integration with 0.8.9.
The new version introduces data loader which we want to use!

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.