Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
c57a2e7
Merge pull request #3 from tensorflow/master
JimClarke5 Oct 8, 2020
09fc07e
Merge pull request #4 from tensorflow/master
JimClarke5 Oct 27, 2020
a99dcb4
Merge pull request #5 from tensorflow/master
JimClarke5 Nov 17, 2020
ba294ea
Merge pull request #6 from tensorflow/master
JimClarke5 Nov 19, 2020
04f419a
Merge pull request #7 from tensorflow/master
JimClarke5 Dec 30, 2020
02e7ebf
Merge pull request #8 from tensorflow/master
JimClarke5 Jan 29, 2021
e0c9ed8
Merge pull request #9 from tensorflow/master
JimClarke5 Feb 1, 2021
5b0374b
Merge pull request #10 from tensorflow/master
JimClarke5 Feb 11, 2021
e038bbd
Merge pull request #11 from tensorflow/master
JimClarke5 Feb 23, 2021
def3051
Merge pull request #13 from tensorflow/master
JimClarke5 Mar 3, 2021
11748ae
Merge pull request #15 from tensorflow/master
JimClarke5 Mar 21, 2021
dc94953
Moved high level tf.nn ops to framework.
JimClarke5 Mar 26, 2021
1878b60
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 26, 2021
9225a48
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 27, 2021
caab79b
Move l2Normalize to MathOps
JimClarke5 Mar 27, 2021
bd072f4
Reformat code, fix javadocs
JimClarke5 Mar 27, 2021
a9412ea
Merge pull request #16 from tensorflow/master
JimClarke5 Apr 9, 2021
d29262b
Add confusionMatrix() method. add Unit test
JimClarke5 Apr 16, 2021
2ff8dfe
Merge pull request #17 from tensorflow/master
JimClarke5 Apr 22, 2021
ee5e38a
Merge pull request #18 from tensorflow/master
JimClarke5 May 1, 2021
26394d6
Merge pull request #19 from tensorflow/master
JimClarke5 May 2, 2021
e0a4a26
Moved high level tf.nn ops to framework.
JimClarke5 Mar 26, 2021
28db4df
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 26, 2021
ba24371
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 27, 2021
4d3f17c
Move l2Normalize to MathOps
JimClarke5 Mar 27, 2021
9e07483
Reformat code, fix javadocs
JimClarke5 Mar 27, 2021
790bf35
Add confusionMatrix() method. add Unit test
JimClarke5 Apr 16, 2021
b4ca97a
Added linalg methods for matmul
JimClarke5 May 2, 2021
e83d26b
add nn ops for sigmoidCrossEntropyWithLogits, softmaxCrossEntropyWith…
JimClarke5 May 2, 2021
e4e65f2
Moved SetOps to FrameworkOps
JimClarke5 May 2, 2021
a2ed723
Added tensordot and reduceLogSumExp
JimClarke5 May 2, 2021
be1fe66
Added frameworkOps for nn and linalg
JimClarke5 May 2, 2021
7b51e7f
Modified to use FrameworkOps
JimClarke5 May 2, 2021
f1c63c0
move nn.raw classes to nn in core, remove nn.raw
JimClarke5 May 2, 2021
f4b75b9
Merge remote-tracking branch 'origin/Framework_Ops' into Framework_Ops
JimClarke5 May 2, 2021
043654b
Update FrameworkOps.java
JimClarke5 May 2, 2021
06c28df
Fix unusual regression error in confustion matrix. Needed to reduceA…
JimClarke5 May 3, 2021
8f33d21
javadoc fixes
JimClarke5 May 3, 2021
a24b8ca
Setting all the optimizers to have useLocking = True (#310)
Craigacp May 4, 2021
94f5b15
Load TF library before computing TString size (#322)
karllessard May 17, 2021
743475d
Update README.md
karllessard May 19, 2021
3648a96
Fix sometimes generating Javadoc for scope param in Ops (#291)
rnett May 21, 2021
ceae489
Use spotless plugin for formating (#308)
rnett May 23, 2021
0f7274e
Quick fix for spotless (#324)
rnett May 24, 2021
ace917b
Temporarily disabling Linux MKL-GPU
karllessard May 26, 2021
3b4533c
Fix Scope name collisions (#248)
rnett May 28, 2021
daeb257
Native functions v2 (#233)
rnett May 31, 2021
19e1c8d
Spotless updates (#331)
rnett Jun 1, 2021
23d6f0b
activations, constraints, initializers, losses, regularizers: move Op…
JimClarke5 Jun 2, 2021
7b5a1ca
Skip tests in check-format job
karllessard Jun 8, 2021
cea76cd
Upgrade for TensorFlow 2.5.0 (#303)
saudet Jun 10, 2021
caed0e8
Skip implementation-less TF_InitKernel
karllessard Jun 11, 2021
b997f12
Upgrade TF version in current snapshots
karllessard Jun 11, 2021
031a0c1
SavedModelBundle leak fix (#335)
Craigacp Jun 11, 2021
b38cc04
Use OP_NAME constant instead of hard coding (#328)
rnett Jun 16, 2021
4d8d24f
Moved high level tf.nn ops to framework.
JimClarke5 Mar 26, 2021
e483792
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 26, 2021
9480126
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 27, 2021
074794b
Move l2Normalize to MathOps
JimClarke5 Mar 27, 2021
7526b7e
Reformat code, fix javadocs
JimClarke5 Mar 27, 2021
0a163c6
Add confusionMatrix() method. add Unit test
JimClarke5 Apr 16, 2021
c234b9a
Added linalg methods for matmul
JimClarke5 May 2, 2021
e024f4b
add nn ops for sigmoidCrossEntropyWithLogits, softmaxCrossEntropyWith…
JimClarke5 May 2, 2021
b108b06
Moved SetOps to FrameworkOps
JimClarke5 May 2, 2021
13b6f0f
Added tensordot and reduceLogSumExp
JimClarke5 May 2, 2021
f1dbb01
Added frameworkOps for nn and linalg
JimClarke5 May 2, 2021
6174a32
Modified to use FrameworkOps
JimClarke5 May 2, 2021
5523896
move nn.raw classes to nn in core, remove nn.raw
JimClarke5 May 2, 2021
b750dd2
Moved high level tf.nn ops to framework.
JimClarke5 Mar 26, 2021
4468be2
Added FrameworkOps analogous to Ops.
JimClarke5 Mar 26, 2021
eb64cd0
Move l2Normalize to MathOps
JimClarke5 Mar 27, 2021
134a11d
Reformat code, fix javadocs
JimClarke5 Mar 27, 2021
1f9626c
Update FrameworkOps.java
JimClarke5 May 2, 2021
7860a71
Fix unusual regression error in confustion matrix. Needed to reduceA…
JimClarke5 May 3, 2021
d967a99
javadoc fixes
JimClarke5 May 3, 2021
e84981f
Rebase with latest master
JimClarke5 Jun 17, 2021
f69e17e
Merge branch 'Framework_Ops' of https://github.com/JimClarke5/java in…
JimClarke5 Jun 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reformat code, fix javadocs
  • Loading branch information
JimClarke5 committed Jun 16, 2021
commit 7526b7e9db059f50cb369ced4f8ee26674852f85
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
*/
public class FrameworkOps {
public final Ops coreOps;
private final Scope scope;

public final NnOps nn;
public final SetsOps sets;
public final MathOps math;
private final Scope scope;

/**
* Creates a FrameworkOps instance with the provided scope
Expand Down Expand Up @@ -62,8 +61,43 @@ private FrameworkOps(Ops coreOps) {
math = new MathOps(this);
}

/**
* Creates an API for building operations in the provided execution environment
*
* @param env the exection environment
* @return the FrameworkOps
*/
public static FrameworkOps create(ExecutionEnvironment env) {
return new FrameworkOps(new Scope(env));
}

/**
* Creates an API for building operations in the default eager execution environment
*
* <p>Invoking this method is equivalent to {@code
* FrameworkOps.create(EagerSession.getDefault())}.
*
* @return the FrameworkOps
*/
public static FrameworkOps create() {
return new FrameworkOps(new Scope(EagerSession.getDefault()));
}

/**
* Creates an API for building operations in the default eager execution environment
*
* @param coreOps the TensorFlow core Ops
* @return the FrameworkOps
*/
public static FrameworkOps create(Ops coreOps) {
return new FrameworkOps(coreOps);
}

/** Returns the current {@link Scope scope} of this API */
/**
* Returns the current {@link Scope scope} of this API
*
* @return the current {@link Scope scope} of this API
*/
public final Scope scope() {
return scope;
}
Expand All @@ -81,6 +115,9 @@ public final Ops coreOps() {
* Returns an API that builds operations with the provided name prefix.
*
* <p>@link Scope#withSubScope(String)}
*
* @param childScopeName the name of the child scope
* @return the FrameworkOps
*/
public FrameworkOps withSubScope(String childScopeName) {
return new FrameworkOps(scope.withSubScope(childScopeName));
Expand All @@ -90,6 +127,9 @@ public FrameworkOps withSubScope(String childScopeName) {
* Returns an API that uses the provided name for an op.
*
* <p>{@link Scope#withName(String)}
*
* @param opName the name of the scope
* @return the FrameworkOps
*/
public FrameworkOps withName(String opName) {
return new FrameworkOps(scope.withName(opName));
Expand All @@ -99,6 +139,9 @@ public FrameworkOps withName(String opName) {
* Returns an API that places the created operations on the device(s) matching the provided spec.
*
* <p>{@link Scope#withDevice(DeviceSpec)}
*
* @param deviceSpec the device specification for the scope
* @return the FrameworkOps
*/
public FrameworkOps withDevice(DeviceSpec deviceSpec) {
return new FrameworkOps(scope.withDevice(deviceSpec));
Expand All @@ -108,32 +151,11 @@ public FrameworkOps withDevice(DeviceSpec deviceSpec) {
* Returns an API that adds operations to the graph with the provided control dependencies.
*
* <p>{@link Scope#withControlDependencies(Iterable)}
*
* @param controls the operations
* @return the FrameworkOps
*/
public FrameworkOps withControlDependencies(Iterable<Op> controls) {
return new FrameworkOps(scope.withControlDependencies(controls));
}

/** Creates an API for building operations in the provided execution environment */
public static FrameworkOps create(ExecutionEnvironment env) {
return new FrameworkOps(new Scope(env));
}

/**
* Creates an API for building operations in the default eager execution environment
*
* <p>Invoking this method is equivalent to {@code
* FrameworkOps.create(EagerSession.getDefault())}.
*/
public static FrameworkOps create() {
return new FrameworkOps(new Scope(EagerSession.getDefault()));
}

/**
* Creates an API for building operations in the default eager execution environment
*
* @param coreOps the TensorFlow core Ops
*/
public static FrameworkOps create(Ops coreOps) {
return new FrameworkOps(coreOps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.tensorflow.framework.op;

import org.tensorflow.Operand;
import org.tensorflow.op.Ops;
import org.tensorflow.op.Scope;
import org.tensorflow.op.core.Constant;
import org.tensorflow.op.core.ReduceSum;
Expand All @@ -26,42 +25,41 @@
import org.tensorflow.op.math.Square;
import org.tensorflow.types.family.TNumber;

import static org.tensorflow.framework.utils.CastHelper.cast;

public class MathOps {
private final Scope scope;
private final Scope scope;

private final FrameworkOps frameworkOps;
private final FrameworkOps frameworkOps;

/**
* Creates Framework {@code nn} Operations
*
* @param frameworkOps the TensorFLow framework Ops
*/
MathOps(FrameworkOps frameworkOps) {
this.scope = frameworkOps.scope();
this.frameworkOps = frameworkOps;
}
/**
* Creates Framework {@code nn} Operations
*
* @param frameworkOps the TensorFLow framework Ops
*/
MathOps(FrameworkOps frameworkOps) {
this.scope = frameworkOps.scope();
this.frameworkOps = frameworkOps;
}

/**
* Normalizes along dimension axis using an L2 norm.
*
* @param x the input
* @param axis Dimension along which to normalize.
* @param <T> the data type for the input and the result
* @return the normalized values based on L2 norm
*/
public <T extends TNumber> Operand<T> l2Normalize(Operand<T> x, int[] axis) {
Operand<T> squareSum =
ReduceSum.create(scope,
Square.create(scope, x),
Constant.vectorOf(scope, axis),
ReduceSum.keepDims(Boolean.TRUE));
Operand<T> invNorm =
Rsqrt.create(scope,
Maximum.create(scope, squareSum,
Cast.create(scope,
Constant.scalarOf(scope, 1e-12F), x.type())));
return Mul.create(scope, x, invNorm);
}
/**
* Normalizes along dimension axis using an L2 norm.
*
* @param x the input
* @param axis Dimension along which to normalize.
* @param <T> the data type for the input and the result
* @return the normalized values based on L2 norm
*/
public <T extends TNumber> Operand<T> l2Normalize(Operand<T> x, int[] axis) {
Operand<T> squareSum =
ReduceSum.create(
scope,
Square.create(scope, x),
Constant.vectorOf(scope, axis),
ReduceSum.keepDims(Boolean.TRUE));
Operand<T> invNorm =
Rsqrt.create(
scope,
Maximum.create(
scope, squareSum, Cast.create(scope, Constant.scalarOf(scope, 1e-12F), x.type())));
return Mul.create(scope, x, invNorm);
}
}
Loading