Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the python layer have attribute "phase" #3995

Merged
merged 2 commits into from
May 4, 2016

Conversation

ZhouYzzz
Copy link
Contributor

I noticed that the python layer cannot tell whether the phase is TRAIN or TEST. This change may bring convenience in some cases. e.g. to me.

class MyLayer(caffe.Layer):
    ... ...
    def forward(self, bottom, top):
        if (self.phase == caffe.TRAIN):
            # do sth.
        else:
            # do sth. else
    ... ...

@ajtulloch
Copy link
Contributor

Looks fine to me. Would you be able to add a test that demonstrates reading out the phase with TRAIN/TEST values as well?

@shaibagon
Copy link
Member

related to issue #3506 -- thanks for implementing this PR!

@ajtulloch
Copy link
Contributor

Looks great to me. Can you squash the commits? @longjon , @shelhamer does this look good to you?

pass

def reshape(self, bootom, top):
top[0].reshape(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Scalars should be 0d; use top[0].reshape().

@longjon
Copy link
Contributor

longjon commented May 4, 2016

I never really got much into phase myself, but this is a clear improvement for the completeness of Python layers, so it seems worthwhile.

However, there are a few style issues, as noted. I'd be happy to merge once these are fixed (and squashed into the existing two commits).

@ZhouYzzz
Copy link
Contributor Author

ZhouYzzz commented May 4, 2016

@longjon Thanks for review and I've fixed it. I'm glad this pr is helpful.

@longjon
Copy link
Contributor

longjon commented May 4, 2016

Looks very clean now, thanks!

@longjon longjon merged commit de8ac32 into BVLC:master May 4, 2016
fxbit pushed a commit to Yodigram/caffe that referenced this pull request Sep 1, 2016
Allow the python layer have attribute "phase"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants