Skip to content

Robodummy#57

Draft
Pranjal-sopho wants to merge 45 commits intoilastik:mainfrom
Pranjal-sopho:robodummy
Draft

Robodummy#57
Pranjal-sopho wants to merge 45 commits intoilastik:mainfrom
Pranjal-sopho:robodummy

Conversation

@Pranjal-sopho
Copy link

No description provided.

Copy link
Member

Choose a reason for hiding this comment

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

__init__ should not raise NotImplementedError. In fact, it is a good style to call super().__init__() in your derived class...

Copy link
Member

Choose a reason for hiding this comment

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

actually, this being work in progress, if you want to indicate that your BaseStrategy is not fully implemented yet, this is fine. (Calling super().__init__() in your derived class would still make sense)

Copy link
Member

Choose a reason for hiding this comment

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

it seems to me that image tiling could nicely be implemented for n dimensions. Maybe have a look at https://github.com/ilastik/lazyflow/blob/dfbb450989d4f790f5b19170383b777fb88be0e8/lazyflow/roi.py#L473 for some inspiration

Copy link
Member

Choose a reason for hiding this comment

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

we should avoid uncommented import statements (just remove this line)

Copy link
Member

Choose a reason for hiding this comment

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

[optional] use a logger, instead of print:

import logging
logger = logging.getLogger(__name__)
...
logger.info("model loaded")

more at https://docs.python.org/3/howto/logging.html

Copy link
Member

Choose a reason for hiding this comment

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

instead of taking the first slice [0, ...] and then expanding the resulting array, you should simplify to take a slice right away:
[0:1, ...]

Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed these paths should be moved to robot config.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, variable names need some polishing. They should be descriptive and have a clear scope.


# run prediction
op = robo.predict()

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here I think algorithm should be read as follows:

# Step 1. Intialization
robo = MrRobot('/home/user/config.yaml')  # Here robot loads all required data
robo.use_strategy(StrategyRandom())
# or even
robo = MrRobot('/home/user/config.yaml', StrategyRandom)

# Step 2. Start
robo.start()  # Start tiktorch server

# Step 3. Prediction loop
while robo.should_stop():
      robo.predict()

# def robo.predict
# 1. labels? = self.strategy.get_next_patch(<relevant data>)
# 2. self.update_training(labels, ...)

# Step 4. Termination
robo.terminate()

Copy link
Member

Choose a reason for hiding this comment

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

yes, I'd vote for

robo = MrRobot('/home/user/config.yaml', StrategyRandom)

Copy link
Member

Choose a reason for hiding this comment

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

the following code should be inside of MrRobot. Currently you mirror parts of the tiktorch api in MrRobot (methods: resume, predict, add). This is fine for convenience, etc, but in it's core MrRobot should implement the way of running a 'user simulation'

Copy link
Member

Choose a reason for hiding this comment

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

the criterion should be configurable

Copy link
Member

Choose a reason for hiding this comment

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

same indexing as in predict method

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 prefer the robot class to perform the 'run', not the strategy. The strategy should effectively implement a sampling strategy. I see this analog to the pytorch sampler.
We might even be able to use the pytorch dataset and the pytorch dataloader for our purposes (and then implement our strategy as a 'Sampler'

Copy link
Member

Choose a reason for hiding this comment

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

including _robo_ in this variable name seems redundant, considering we are in the MrRobot class

Copy link
Member

Choose a reason for hiding this comment

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

counter as a property name is a bit confusing here (it is not obvious what's being counted)
I would suggest

  • self.iterations_max
  • self.iterations_done

if that is what you intend

Copy link
Member

Choose a reason for hiding this comment

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

you should run black on your code (this will convert ' to " where possible)

Copy link
Member

Choose a reason for hiding this comment

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

no need to open this file every time add is called. This should be in __init__. use self.file here

Copy link
Member

Choose a reason for hiding this comment

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

"cremi_data" should instead be something like "raw_data_path" and "label_data_path" (1. cremi is just an example. 2. raw data and label data are not necessarily in the same file)

Copy link
Member

Choose a reason for hiding this comment

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

you should not hardcode that the data is 3 dimensional, use tuples to index instead

Copy link
Member

Choose a reason for hiding this comment

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

it would be great if you could add some doc strings to communicate what your methods (and classes) are for

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

also: no need to call this method base_patch. naming it patch and calling super().patch() in a derived class works as well (even when you overwrite patch in the derived class, that's what the super(), resolves for you)
some more 'how-to-inherit' here: https://www.python.org/dev/peps/pep-0008/#designing-for-inheritance

.py~ No newline at end of file
.py~
*.nn
*.hdf
Copy link
Member

Choose a reason for hiding this comment

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

there is no need to ignore .nn and .hdf files (as there are none in the repo). Pls remove

Copy link
Member

Choose a reason for hiding this comment

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

we decided that changing strategy is a strategy of its own...

Copy link
Member

Choose a reason for hiding this comment

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

do not hard code 'personal' paths, etc...
suggestion:
get absolute path of mr_robot.py and deduct the absolute path to mr_robot folder:

mr_robot_folder = os.path.dirname(os.path.abspath(__file__))

add log folder to it:

logdir=os.path.join(mr_robot_folder, "logs")

Copy link
Member

Choose a reason for hiding this comment

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

delete if this is no longer needed

Copy link
Member

@FynnBe FynnBe Jul 12, 2019

Choose a reason for hiding this comment

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

do not hard code use of a specific gpu, use environment variables

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.

3 participants

Comments