Git Product home page Git Product logo

nikitadurasov / masksembles Goto Github PK

View Code? Open in Web Editor NEW
94.0 5.0 12.0 259 KB

Official repository for the paper "Masksembles for Uncertainty Estimation" (CVPR 2021).

Home Page: https://www.norange.io/projects/masksembles/

License: MIT License

Python 100.00%
uncertainty-estimation deep-learning computer-vision tensorflow torch uncertainty-quantification uncertainty-neural-networks paper out-of-distribution-detection

masksembles's People

Contributors

dkoguciuk avatar nikitadurasov avatar ulriks9 avatar ymetz 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

Watchers

 avatar  avatar  avatar  avatar  avatar

masksembles's Issues

Number of ways to split should evenly divide the split dimension

Hello,

I'm trying to use the layer, and I'm facing the below error:

batch_size = 128
epochs = 5

model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, validation_split=0.1)
InvalidArgumentError:  Number of ways to split should evenly divide the split dimension, but got split_dim 0 (size = 29) and num_split 4
	 [[node sequential_1/masksembles2d/split (defined at /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/framework/ops.py:1751) ]] [Op:__inference_distributed_function_14069]

My Network looks like this:

model = keras.Sequential(
    [
        keras.Input(shape=input_shape),
        layers.Conv2D(32, kernel_size=(3, 3), activation="elu"),
        Masksembles2D(4, 2.0), # adding Masksembles2D
        layers.MaxPooling2D(pool_size=(2, 2)),
     
        layers.Conv2D(64, kernel_size=(3, 3), activation="elu"),
        Masksembles2D(4, 2.0), # adding Masksembles2D
        layers.MaxPooling2D(pool_size=(2, 2)),
     
        layers.Flatten(),
        Masksembles1D(4, 2.), # adding Masksembles1D
        layers.Dense(num_classes, activation="softmax"),
    ]
)

model.summary()

My amount of data is 1170 records of train, and 0.1 to the validation.

What should I notice before using this model?

Thanks.

Mask generation functions *sometimes* fail to produce proper masks

Here is a problem. When result from here fails to produce proper masks -- the number of features in those masks isn't equal to the number of channels required.

The current solution is just to try searching for a new value of scale parameter via grid-search -- trying values from np.linspace. This solution is far from perfect since for some function configurations it fails to find proper scale. Need to implement something more sophisticated like binary search or something so it would work for every possible configuration.

How to use masksembles?

Hi, thank you for your excellent work!
I have read the masksembles layer code, but I have a little issue with understanding how to use it.
Does it mean replacing the dropout layer with masksembles layer in practice?

Could you give a more detailed example?

I have run the following test code sucessfully.
layer = Masksembles1D(20, 10,2.) output=layer(torch.randn([40,20])) print(output)

Question: Uncertainty Types

Hey @nikitadurasov! ๐Ÿ‘‹

When using the Masksembles method, I want to make a distinction between the different types of uncertainty (model/epistemic, label/aleatoric, and distributional/dataset shift). I noticed it wasn't explicitly stated what kind/s of uncertainty were being estimated through this method, but since the experiments focus on OOD detection, would it be fair to say this is mostly for dataset shift?

Lack of implementation for Keras and Tensorflow

Repo lacks implementation for Keras / Tensorflow. Need to update code accordingly and write documentation.

  • add Masksembles2D and Masksembles1D for Keras
  • write documentation and comments for implementation
  • update README

Using maskensemble to the shape of the tensor [B, H, W]

Hi,

I have read the paper about masksembles, congratulations for the article. I'm trying to adapt to my problem. In my research, I don't work with images and the shape of the tensor is [B, H, W].

How can I adapt the maskensemble to the shape of my problem?

Masksembles - a couple of questions

Hi @nikitadurasov ,

I have a couple of questions about Masksembles:

  1. What is the difference between Masksembles and Batchensemble? Is there any particular reason you do not discuss it in the paper?
  2. As far as I understand the general idea of Masksembles and Batchensemble is pretty similar: they don't have this scale property to move between dropout and naive ensemble, however, their mask is learnable, which brings the question, if those two ideas could be combined?
  3. I've been developing a somewhat similar approach. I was feeding the same data to all the modes (in contrast to your approach) and was forcing diversity between modes' predictions by maximizing the L1 difference of predictions. Have you tried enforcing diversity anyhow?

Best,
Daniel

uncertainty quantification

Hi nice paper.

I was wondering from the methods, could you get a quantified number of uncertainty for the model output?

Invalid f-strings

Hello and thank you for your interesting work !

Small issue though

Masksembles Implementation to regression-base problems.

Hi @nikitadurasov, I need help on how to implement masksembles to a regression problem. I am not using image data. I have a set of features that I am using to predict a continuous dependent variable. First of all, my code implementation does not seem to be working. Moreover, it is still not clear to me how to get the uncertainties on the predictions for this task using masksembles. I think a quick tutorial on how to tackle this kind of task using masksembles will be helpful.

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.