Skip to content

Commit d3b681e

Browse files
committed
fix unit test.
1 parent aa13352 commit d3b681e

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

src/TensorFlowNET.Core/Keras/Engine/Layer.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ public Tensor Apply(Tensor inputs, bool is_training = false)
138138
{
139139
nameScope = name;
140140
}
141-
else
142-
{
143-
throw new NotImplementedException("");
144-
}
145141

146142
// using var graph = tf.keras.backend.get_graph().as_default();
147143
if (!inputs.IsEagerTensor)

src/TensorFlowNET.Core/Layers/Layer.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,19 @@ public Tensor[] __call__(Tensor inputs,
8383
auxiliary_name_scope: false);
8484
}
8585

86-
Tensor[] outputs = null;
86+
Tensor outputs = null;
8787
tf_with(scope_context_manager, scope2 =>
8888
{
8989
_current_scope = scope2;
9090
// Actually call layer
91-
/*outputs = base.Apply(new Tensor[] { inputs },
92-
is_training: training);*/
91+
outputs = base.Apply(inputs);
9392
});
9493

9594

9695
// Update global default collections.
9796
_add_elements_to_collection(updates.ToArray(), new string[] { tf.GraphKeys.UPDATE_OPS });
9897

99-
return outputs;
98+
return new Tensor[] { outputs };
10099
}
101100

102101
protected virtual void _add_elements_to_collection(Operation[] elements, string[] collection_list)

src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ protected override Tensor call(Tensor inputs, bool is_training = false, Tensor s
8787
// array_ops.split(value: state, num_or_size_splits: 2, axis: one);
8888
throw new NotImplementedException("BasicLstmCell call");
8989
}
90-
var gate_inputs = math_ops.matmul(array_ops.concat(new[] { inputs, h }, 1), _kernel as RefVariable);
91-
gate_inputs = nn_ops.bias_add(gate_inputs, _bias as RefVariable);
90+
var gate_inputs = math_ops.matmul(array_ops.concat(new[] { inputs, h }, 1), _kernel.AsTensor());
91+
gate_inputs = nn_ops.bias_add(gate_inputs, _bias.AsTensor());
9292

9393
// i = input_gate, j = new_input, f = forget_gate, o = output_gate
9494
var tensors = array_ops.split(value: gate_inputs, num_split: 4, axis: one);

test/TensorFlowNET.UnitTest/Keras/LayersTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void Dense()
5252
// Create a `Sequential` model and add a Dense layer as the first layer.
5353
var model = tf.keras.Sequential();
5454
model.add(tf.keras.Input(shape: 16));
55-
model.add(tf.keras.layers.Dense(32, activation: tf.keras.activations.Relu));
55+
model.add(tf.keras.layers.Dense(32, activation: "relu"));
5656
// Now the model will take as input arrays of shape (None, 16)
5757
// and output arrays of shape (None, 32).
5858
// Note that after the first layer, you don't need to specify

0 commit comments

Comments
 (0)