Skip to content

Conversation

@KonstantinWilleke
Copy link
Contributor

No description provided.

Copy link
Member

@christoph-blessing christoph-blessing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run black over this and check if all of the tests still pass?

mei/modules.py Outdated
"""

def __init__(self, model: Module, constraint: int, forward_kwargs: Dict[str, Any] = None):
def __init__(self, model: Module, constraint: int, target_fn=None, forward_kwargs: Dict[str, Any] = None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a type annotation for the new argument.

model: A PyTorch module.
constraint: An integer representing the index of a neuron in the model's output. Only the value corresponding
to that index will be returned.
target_fn: Callable, that gets as an input the constrained output of the model.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this new argument needed?

mei/modules.py Outdated
"""
output = self.model(x, *args, **self.forward_kwargs, **kwargs)
return output[:, self.constraint]
return self.target_fn(output[:, self.constraint])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be tested if the model output gets passed to the function and if the return value of the function gets returned.



class RandomNormalNullChannel(InitialGuessCreator):
"""Used to create an initial guess tensor filled with values distributed according to a normal distribution."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docstring is the same as the one for the RandomNormal initial guess creator. This might confuse people as to what the differences between the two are.


_create_random_tensor = randn

def __init__(self, null_channel, null_value=0):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see type annotations here.

self.null_value = null_value

def __call__(self, *shape):
"""Creates a random initial guess from which to start the MEI optimization process given a shape."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also the same docstring as the one of the __call__ method of the RandomNormal` initial guess creator.

mei/initial.py Outdated
return inital

def __repr__(self):
return f"{self.__class__.__qualname__}()" No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is missing a newline at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants