File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
tensorflow-core/tensorflow-core-api/src
gen/annotations/org/tensorflow/op Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -347,10 +347,10 @@ public final class Ops {
347
347
348
348
public final SignalOps signal ;
349
349
350
- public final QuantizationOps quantization ;
351
-
352
350
public final TrainOps train ;
353
351
352
+ public final QuantizationOps quantization ;
353
+
354
354
private final Scope scope ;
355
355
356
356
private Ops (Scope scope ) {
@@ -372,8 +372,8 @@ private Ops(Scope scope) {
372
372
math = new MathOps (this );
373
373
audio = new AudioOps (this );
374
374
signal = new SignalOps (this );
375
- quantization = new QuantizationOps (this );
376
375
train = new TrainOps (this );
376
+ quantization = new QuantizationOps (this );
377
377
}
378
378
379
379
/**
@@ -2755,11 +2755,10 @@ public Init init() {
2755
2755
*
2756
2756
* <p>Registered initializers are then grouped as a single unit of computation by adding
2757
2757
* and executing an {@link org.tensorflow.op.core.Init#create(Scope) init} operation from a graph
2758
- * session.
2758
+ * session. This is a no-op if executed in an eager session.
2759
2759
*
2760
2760
* @param scope
2761
2761
* @param initializer
2762
- * @throws IllegalArgumentException if the execution environment in scope is not a graph
2763
2762
* @see org.tensorflow.op.core.Init#create(Scope) init
2764
2763
*/
2765
2764
public void initAdd (Op initializer ) {
Original file line number Diff line number Diff line change @@ -490,6 +490,19 @@ public void run(Op op) {
490
490
runner ().addTarget (op .op ()).run ();
491
491
}
492
492
493
+
494
+ /**
495
+ * Execute the graph's initializers.
496
+ *
497
+ * <p>This method is equivalent to {@code session.run(Ops.create(session.graph).init())}.
498
+ *
499
+ */
500
+ public void runInit (){
501
+ Runner runner = runner ();
502
+ graph .initializers ().forEach (runner ::addTarget );
503
+ runner .run ();
504
+ }
505
+
493
506
/**
494
507
* Saves the actual state of the variables of this session's graph.
495
508
*
Original file line number Diff line number Diff line change @@ -89,21 +89,19 @@ public static Init create(Scope scope) {
89
89
*
90
90
* <p>Registered initializers are then grouped as a single unit of computation by adding
91
91
* and executing an {@link org.tensorflow.op.core.Init#create(Scope) init} operation from a graph
92
- * session.
92
+ * session. This is a no-op if executed in an eager session.
93
93
*
94
94
* @param scope
95
95
* @param initializer
96
- * @throws IllegalArgumentException if the execution environment in scope is not a graph
97
96
* @see org.tensorflow.op.core.Init#create(Scope) init
98
97
*/
99
98
@ Endpoint (name = "initAdd" )
100
99
public static void add (Scope scope , Op initializer ) {
101
100
ExecutionEnvironment exEnv = scope .env ();
102
- if (!(exEnv instanceof Graph )) {
103
- throw new IllegalArgumentException ("initAdd is only supported on Graph sessions." );
101
+
102
+ if (exEnv .isGraph ()) {
103
+ ((Graph ) exEnv ).addInitializer (initializer );
104
104
}
105
- Graph graph = (Graph ) exEnv ;
106
- graph .addInitializer (initializer );
107
105
}
108
106
109
107
private Init (Operation operation ) {
You can’t perform that action at this time.
0 commit comments