Browse Source

add tf.nn.swish activation function.

tags/v0.13
Oceania2018 5 years ago
parent
commit
0dd0e4b71e
2 changed files with 12 additions and 0 deletions
  1. +4
    -0
      src/TensorFlowNET.Core/APIs/tf.nn.cs
  2. +8
    -0
      src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs

+ 4
- 0
src/TensorFlowNET.Core/APIs/tf.nn.cs View File

@@ -111,6 +111,7 @@ namespace Tensorflow
name: name);

public IActivation relu() => new relu();
public IActivation swish() => new swish();

public Tensor relu(Tensor features, string name = null) => gen_nn_ops.relu(features, name);

@@ -206,6 +207,9 @@ namespace Tensorflow

public Tensor softmax_cross_entropy_with_logits_v2(Tensor labels, Tensor logits, int axis = -1, string name = null)
=> nn_ops.softmax_cross_entropy_with_logits_v2_helper(labels, logits, axis: axis, name: name);

public Tensor sigmoid<T>(T x, string name = null)
=> math_ops.sigmoid(x, name: name);
}
}
}

+ 8
- 0
src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs View File

@@ -102,6 +102,14 @@ namespace Tensorflow.Operations.Activation
}
}

public class swish : IActivation
{
public Tensor Activate(Tensor x, string name = null)
{
return tf.multiply(x, tf.nn.sigmoid(x));
}
}

public class linear : IActivation
{
public Tensor Activate(Tensor x, string name = null)


Loading…
Cancel
Save