-
Notifications
You must be signed in to change notification settings - Fork 120
Class config #21
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
Class config #21
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
=======================================
- Coverage 92.82% 90% -2.83%
=======================================
Files 11 12 +1
Lines 516 500 -16
=======================================
- Hits 479 450 -29
- Misses 37 50 +13 |
|
This looks great to me. I just made some small modifications (~15min) to get this branch running on the following examples. I've manually tested that all visualizations work for these examples. Let's review this now! And I'd say, let's not worry about documentation or the codecov report for now - we can fix that in separate PR's that we'll merge into this branch. |
tests/test_picasso.py
Outdated
| class TestTensorflowBackend: | ||
| from picasso.ml_frameworks.tensorflow.model import TFModel | ||
| class TFTestModel(TFModel): | ||
| TF_PREDICT_VAR = 'Softmax:0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this overrides the configuration file
picasso/examples/tensorflow/model.py
Outdated
|
|
||
| class TensorflowMNISTModel(TFModel): | ||
|
|
||
| TF_INPUT_VAR = 'convolution2d_input_1:0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is configuration and shouldn't be overridden here
|
@rhsimplex I saw you made a few updates:
I agree with (1) because these attributes are set in an instance method (specifically, the instance constructor), which makes them class attributes. Thus, they should be lower case. Furthermore, in TFModel, these are lower-case attributes, and these attributes should be named the same way in TFModel and KerasModel. (The notion that these attributes should have the same name in TFModel and KerasModel will be clearer when we convert I disagree with (2) for 2 reasons. Aside from breaking the convention that class attributes be upper-case, more importantly, it is bad style to override class attributes in an instance. Class attributes belong to the class, so generally users expect that they are untouched by an instance. Instances should only modify instance attributes, which they own. In this particular case, I'd recommend converting the class attributes' names back to upper case and then defining the TFModel constructor as follows: Now, this is still bad style, since generally we shouldn't be using hasattr checks. But we can fix this in the separate formatting/styling PR. |
|
@jwayne, I'm assuming you are using PEP8 code style in picasso. According to PEP8 all caps is reserved for constants not for class variables. Class variables should lead with a double under score (e.g. here the reference to the section in PEP8: https://www.python.org/dev/peps/pep-0008/#method-names-and-instance-variables another question: why are you not specifying the parameters for the models? In my opinion using def __init__(self,
tf_predict_var=BaseModel.__tf_predit_var,
tf_input_var=BaseModel.__tf_input_var):
super(TFModel, self).__init__(*args, **kwargs)
self.tf_predict_var = tf_predict_var
self.tf_input_var = tf_input_var |
|
@jwayne @jan-xyz I agree the casing is not correct! But since I'm trying for the minimal delta for the current feature, and they are upper case and lower case throughout the code, I just changed them all to the same case to make the test pass (since the visualizations refer to the lower-case versions). We're doing another PR with style changes on top of this one, we can fix it there if that's alright (and even merge it in to this one before merging to master). EDIT @jwayne haha i see you said the same thing in the last sentence of your post. I should read more. |
|
@rhsimplex Ok let's fix it in the other pr then. It was unclear to me
whether we wanted new code in this pr to follow style guides or not. To me
that made sense but if we're fixing it in the next pr anyway then I don't
care since the result is the same.
…On Thu, Jun 15, 2017, 10:07 AM Ryan Henderson ***@***.***> wrote:
@jwayne <https://github.com/jwayne> @jan-xyz <https://github.com/jan-xyz>
I agree the casing is not correct! But since I'm trying for the minimal
delta for the current feature, and they are upper case and lower case
throughout the code, I just changed them all to the same case to make the
test pass (since the visualizations refer to the lower-case versions).
We're doing another PR with style changes on top of this one, we can fix
it there if that's alright (and even merge it in to this one before merging
to master).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABPiiYvdQUP1bNXT09Eaxe7oKsnhgSEGks5sEOY1gaJpZM4N4e7L>
.
|
|
@jan-xyz yes that's what I meant, thanks. But in this case TF_PREDICT_VAR,
etc are class constants. Anyway this is now a moot point since we will fix
in next pr.
…On Thu, Jun 15, 2017, 10:56 AM Josh Chen ***@***.***> wrote:
@rhsimplex Ok let's fix it in the other pr then. It was unclear to me
whether we wanted new code in this pr to follow style guides or not. To me
that made sense but if we're fixing it in the next pr anyway then I don't
care since the result is the same.
On Thu, Jun 15, 2017, 10:07 AM Ryan Henderson ***@***.***>
wrote:
> @jwayne <https://github.com/jwayne> @jan-xyz <https://github.com/jan-xyz>
> I agree the casing is not correct! But since I'm trying for the minimal
> delta for the current feature, and they are upper case and lower case
> throughout the code, I just changed them all to the same case to make the
> test pass (since the visualizations refer to the lower-case versions).
>
> We're doing another PR with style changes on top of this one, we can fix
> it there if that's alright (and even merge it in to this one before merging
> to master).
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#21 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/ABPiiYvdQUP1bNXT09Eaxe7oKsnhgSEGks5sEOY1gaJpZM4N4e7L>
> .
>
|
|
If it looks ok to you @jwayne, then I'll update the documentation and merge (or leave this branch separate for now, whichever you prefer). |
c1667d6 to
a7c7255
Compare
|
@rhsimplex I finished making the code style and formatting changes in the last 2 commits. I'd recommend looking at them independently. I think they should be relatively parseable, let me know and thanks! |
picasso/__init__.py
Outdated
| ' setting. The settings and utility functions' | ||
| ' have been changed as of version v0.2.0 (and ' | ||
| 'you\'re using {}). Changing to the updated ' | ||
| ' settings is trivial: see xxxxxxx.'.format(__version__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember to update the xxxxx
picasso/__init__.py
Outdated
| 'BACKEND_POSTPROCESSOR_NAME', | ||
| 'BACKEND_POSTPROCESSOR_PATH', | ||
| 'BACKEND_PROB_DECODER_NAME', | ||
| 'BACKEND_PROB_DECODER_PATH'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably want to add DATA_DIR here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
@josh for discussion - minimal delta for the configuration change w.r.t. #10