Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 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
28a34dd
Clean up generics, remove generics from class and fix call method to …
JimClarke5 Mar 3, 2021
309b834
resynch with master, for some reason when I build on mac, the order f…
JimClarke5 Mar 3, 2021
def3051
Merge pull request #13 from tensorflow/master
JimClarke5 Mar 3, 2021
3a9ae37
Merge branch 'master' of https://github.com/JimClarke5/java into Gene…
JimClarke5 Mar 3, 2021
c5d37bf
Add GeLU activation present in TF 2.4
JimClarke5 Mar 4, 2021
11f8ac9
Fix @param<T> and reformat
JimClarke5 Mar 4, 2021
40a95af
Fix JavaDoc to add @param <T>
JimClarke5 Mar 6, 2021
d0e8de9
Refactor to add generic to base class and change signature of call me…
JimClarke5 Mar 6, 2021
478b78a
Add check for scalar.
JimClarke5 Mar 6, 2021
f53fa08
Change to accept TString value.
JimClarke5 Mar 7, 2021
79594da
Fix GeLU equations with separate Operands
JimClarke5 Mar 9, 2021
112c740
Fix Constant to handle TString properly
JimClarke5 Mar 9, 2021
61e6206
Added Stddev check for not less than 0.
JimClarke5 Mar 9, 2021
3b4b607
Fix fix fill to cast the 1 to the approriate type before the fill
JimClarke5 Mar 9, 2021
98df654
Code reformat
JimClarke5 Mar 9, 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
Add check for scalar.
  • Loading branch information
JimClarke5 committed Mar 6, 2021
commit 478b78aa7715e202be059a86ea8e8d82bce64f9d
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ public class Constant extends BaseInitializer<TType> {
*
* @param tf the TensorFlow Ops
* @param value the value used for the constant.
* @throws IllegalArgumentException if value is not a scalar.
*/
public Constant(Ops tf, Operand<? extends TType> value) {
super(tf);
if (!value.shape().isScalar()) {
throw new IllegalArgumentException("value must be scalar, got shape : " + value.shape());
}
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.tensorflow.types.*;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;

/** Test the Constant initializer */
public class ConstantTest {
Expand Down Expand Up @@ -135,6 +134,23 @@ public void testCallString() {
});
}

/** Test of call method, of class Constant. */
@Test
public void testCallNonScalar() {
for (TestSession.Mode tfMode : tfModes)
assertThrows(
java.lang.IllegalArgumentException.class,
() -> {
try (TestSession session = TestSession.createTestSession(tfMode)) {
Ops tf = session.getTF();
Shape shape = Shape.of(2, 2);

Constant instance = new Constant(tf, tf.constant(new int[] {1, 2}));
instance.call(tf.constant(shape), TInt32.class);
}
});
}

/** Test of call method, of class Constant. */
@Test
public void testCallBool() {
Expand Down