Browse Source

fix unit test.

tags/v0.20
Oceania2018 5 years ago
parent
commit
d3b681e909
4 changed files with 6 additions and 11 deletions
  1. +0
    -4
      src/TensorFlowNET.Core/Keras/Engine/Layer.cs
  2. +3
    -4
      src/TensorFlowNET.Core/Layers/Layer.cs
  3. +2
    -2
      src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs
  4. +1
    -1
      test/TensorFlowNET.UnitTest/Keras/LayersTest.cs

+ 0
- 4
src/TensorFlowNET.Core/Keras/Engine/Layer.cs View File

@@ -138,10 +138,6 @@ namespace Tensorflow.Keras.Engine
{
nameScope = name;
}
else
{
throw new NotImplementedException("");
}

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


+ 3
- 4
src/TensorFlowNET.Core/Layers/Layer.cs View File

@@ -83,20 +83,19 @@ namespace Tensorflow.Layers
auxiliary_name_scope: false);
}

Tensor[] outputs = null;
Tensor outputs = null;
tf_with(scope_context_manager, scope2 =>
{
_current_scope = scope2;
// Actually call layer
/*outputs = base.Apply(new Tensor[] { inputs },
is_training: training);*/
outputs = base.Apply(inputs);
});


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

return outputs;
return new Tensor[] { outputs };
}

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


+ 2
- 2
src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs View File

@@ -87,8 +87,8 @@ namespace Tensorflow
// array_ops.split(value: state, num_or_size_splits: 2, axis: one);
throw new NotImplementedException("BasicLstmCell call");
}
var gate_inputs = math_ops.matmul(array_ops.concat(new[] { inputs, h }, 1), _kernel as RefVariable);
gate_inputs = nn_ops.bias_add(gate_inputs, _bias as RefVariable);
var gate_inputs = math_ops.matmul(array_ops.concat(new[] { inputs, h }, 1), _kernel.AsTensor());
gate_inputs = nn_ops.bias_add(gate_inputs, _bias.AsTensor());

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


+ 1
- 1
test/TensorFlowNET.UnitTest/Keras/LayersTest.cs View File

@@ -52,7 +52,7 @@ namespace TensorFlowNET.UnitTest.Keras
// Create a `Sequential` model and add a Dense layer as the first layer.
var model = tf.keras.Sequential();
model.add(tf.keras.Input(shape: 16));
model.add(tf.keras.layers.Dense(32, activation: tf.keras.activations.Relu));
model.add(tf.keras.layers.Dense(32, activation: "relu"));
// Now the model will take as input arrays of shape (None, 16)
// and output arrays of shape (None, 32).
// Note that after the first layer, you don't need to specify


Loading…
Cancel
Save