-
Notifications
You must be signed in to change notification settings - Fork 214
Add initializers #116
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
Add initializers #116
Conversation
Fixed dependencies in pom.xml
…hod. This allows the NAME to be used elsewhere instead of hardcoding the string.
…coding the string. added methods isFloating(), isInteger(), isNUmeric(), isBoolean() and isString()
…ng OP_NAME" to each generated operation.
…EntropyWitLogits() Added tf.nn.sparesSoftmaxCrossEntropyWithLogits() and tf.nn.raw.sparesSoftmaxCrossEntropyWithLogits() Added tf.nn.sigmoidCrossEntropyWithLogits()
…Logits to org.tensorflow.op.nn.raw
fix javadoc, fix casts
…yWithLogits.java to nn.raw, added new versions of these to NnOps
…maxCrossEntropyWithLogits()
…maxCrossEntropyWithLogits()
…x JavaDoc. Change from snake case to camel case.
…x JavaDoc. Change from snake case to camel case.
…Java files for some Ops. This also resulted in new generated source that are also committed.
…gmoidCrossEntropyWithLogits.java, and SparseSoftmaxCrossEntropyWithLogits.java under package org.tensorflow.op.nn in
…asy inclusion of a default optimizer. Cleaned up JavaDoc
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.
The seeds should be primitives not boxed primitives that'll let you elide the conditional logic. Either that or document that if the seed is null it defaults to zero (but I'd prefer them to be primitives). Other than that and a missing bit of Javadoc in VarianceScaling this looks good and is ready to be merged.
for (; i < dimsShape.numDimensions() - 1; i++) num_rows *= dimsShape.size(i); | ||
long num_cols = dimsShape.size(i); | ||
Shape flat_shape = Shape.of(Math.max(num_rows, num_cols), Math.min(num_rows, num_cols)); | ||
long lseed = this.seed == null ? 0L : this.seed; |
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 isn't necessary if we make seed be a long
not a Long
. I think we should prevent people from passing nulls to the constructor.
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.
LGTM, thanks Jim.
} | ||
boolean isSquare = shape.size(0) == shape.size(1); | ||
long diag_size = Math.min(shape.size(0), shape.size(1)); | ||
Shape diagShape = Shape.of(diag_size); |
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.
There is still a few variables like this in the PR using snake_case instead of camelCase.
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.
I think we all agree that in general, this PR is ready to be merged. Up to you @JimClarke5 to update now the small details we've mentioned or do it later (I like though the idea of moving isCompatibleWith
to the ndarray
library).
Another thing, I have some concerns about the naming of some classes, like I understand though that if we prefix/suffix this class, we should do it for all of our initializers as well (and what about our current optimizers?). So maybe we should just find another name for these? Note that we are never protected from conflicts with the ops classes since most of them are generated. For example one day, a |
I have fixed the snake_case issues. The names are the same ones used in Keras. IMO, most users will use |
Yeah, but if they assign |
It's besides the point but Shape already conflicts with If you want, I can rename them all to |
I have moved |
Exactly the case I had in mind as well. They can just keep a reference to |
So this PR is good to go, thanks @JimClarke5 ! Please review the conflict raised in |
The conflict in Did we want to rename |
If we do it for the initializers, we should do it for the optimizers as well for consistency. That is why I think it can be out of scope of this PR to make that change and we can do it later, wdyt? |
I vote we leave it as is for now. We still have losses and metrics to go, so by then we can get a holistic view how to handle this issue. |
@JimClarke5 , I’m sorry to tell you this but it looks like your PR has new conflicts since I’ve updated the master branch for the next development iteration. Can you please fix them so we can merge it? |
Ok that’s fine, it just had trouble to rebase but a simple merge did the trick, thanks for your great work! |
So I don’t have to fix anything, right? |
Nope, it’s already merged! I had to do a few quick fixes in the javadoc though to be able to deploy this new snapshot, we should enable these lint checks locally so a developer can catch the errors upfront, there is a story about it: #7 |
This PR adds initializers to
tensorflow-framework
. The classes inherit fromBaseInitializer
which implementsInitializer
which is also defined as aFunctional
interface so that anInitializer
can be a lambda. Unit Test cases are also provided.I have also included
utils.ShapeUtils
. Some methods inShapeUtils
,might be considered to be a part of
org.tensorflow.ndarray.Shape
. The other methods bridgeOperands
to aorg.tensorflow.ndarray.Shape
, so probably don't belong in thendarray
module.This PR is not dependent on any other PR.