| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,6 +101,8 @@ public Tensor embedding_lookup(Tensor @params, | |||
| 101 | 101 | name: name); | |
| 102 | 102 | ||
| 103 | 103 | public IActivation relu() => new relu(); | |
| 104 | + | ||
| 105 | + | ||
| 104 | 106 | public IActivation swish() => new swish(); | |
| 105 | 107 | public IActivation tanh() => new tanh(); | |
| 106 | 108 | ||
@@ -111,6 +113,9 @@ public Tensor tanh(Tensor x, string name = null) | |||
| 111 | 113 | public Tensor relu(Tensor features, string name = null) | |
| 112 | 114 | => gen_nn_ops.relu(features, name); | |
| 113 | 115 | ||
| 116 | + public Tensor relu6(Tensor features, string name = null) | ||
| 117 | + => gen_nn_ops.relu6(features, name); | ||
| 118 | + | ||
| 114 | 119 | public Tensor[] fused_batch_norm(Tensor x, | |
| 115 | 120 | Tensor scale, | |
| 116 | 121 | Tensor offset, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ public interface IActivationsApi | |||
| 32 | 32 | Activation Linear { get; } | |
| 33 | 33 | ||
| 34 | 34 | Activation Relu { get; } | |
| 35 | + Activation Relu6 { get; } | ||
| 35 | 36 | ||
| 36 | 37 | Activation Sigmoid { get; } | |
| 37 | 38 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,9 @@ public ILayer LayerNormalization(Axis? axis, | |||
| 180 | 180 | public ILayer Normalization(Shape? input_shape = null, int? axis = -1, float? mean = null, float? variance = null, bool invert = false); | |
| 181 | 181 | public ILayer LeakyReLU(float alpha = 0.3f); | |
| 182 | 182 | ||
| 183 | + public ILayer ReLU6(); | ||
| 184 | + | ||
| 185 | + | ||
| 183 | 186 | public IRnnCell LSTMCell(int uints, | |
| 184 | 187 | string activation = "tanh", | |
| 185 | 188 | string recurrent_activation = "sigmoid", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,11 @@ public class Activations: IActivationsApi | |||
| 20 | 20 | Name = "relu", | |
| 21 | 21 | ActivationFunction = (features, name) => tf.Context.ExecuteOp("Relu", name, new ExecuteOpArgs(features)) | |
| 22 | 22 | }; | |
| 23 | + private static Activation _relu6 = new Activation() | ||
| 24 | + { | ||
| 25 | + Name = "relu6", | ||
| 26 | + ActivationFunction = (features, name) => tf.Context.ExecuteOp("Relu6", name, new ExecuteOpArgs(features)) | ||
| 27 | + }; | ||
| 23 | 28 | private static Activation _sigmoid = new Activation() | |
| 24 | 29 | { | |
| 25 | 30 | Name = "sigmoid", | |
@@ -55,6 +60,7 @@ static Activations() | |||
| 55 | 60 | _nameActivationMap = new Dictionary<string, Activation>(); | |
| 56 | 61 | ||
| 57 | 62 | RegisterActivation(_relu); | |
| 63 | + RegisterActivation(_relu6); | ||
| 58 | 64 | RegisterActivation(_linear); | |
| 59 | 65 | RegisterActivation(_sigmoid); | |
| 60 | 66 | RegisterActivation(_softmax); | |
@@ -65,6 +71,7 @@ static Activations() | |||
| 65 | 71 | public Activation Linear => _linear; | |
| 66 | 72 | ||
| 67 | 73 | public Activation Relu => _relu; | |
| 74 | + public Activation Relu6 => _relu6; | ||
| 68 | 75 | ||
| 69 | 76 | public Activation Sigmoid => _sigmoid; | |
| 70 | 77 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + using Tensorflow.Keras.ArgsDefinition; | ||
| 5 | + using Tensorflow.Keras.Engine; | ||
| 6 | + using Tensorflow.Common.Types; | ||
| 7 | + using static Tensorflow.Binding; | ||
| 8 | + | ||
| 9 | + namespace Tensorflow.Keras.Layers | ||
| 10 | + { | ||
| 11 | + /// <summary> | ||
| 12 | + /// Leaky version of a Rectified Linear Unit. | ||
| 13 | + /// </summary> | ||
| 14 | + public class ReLu6 : Layer | ||
| 15 | + { | ||
| 16 | + public ReLu6() : base(new LayerArgs { }) | ||
| 17 | + { | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||
| 21 | + { | ||
| 22 | + return tf.nn.relu6(inputs); | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -735,6 +735,15 @@ public ILayer LeakyReLU(float alpha = 0.3f) | |||
| 735 | 735 | }); | |
| 736 | 736 | ||
| 737 | 737 | ||
| 738 | + /// <summary> | ||
| 739 | + /// Leaky version of a Rectified Linear Unit. | ||
| 740 | + /// </summary> | ||
| 741 | + /// <param name="alpha">Negative slope coefficient.</param> | ||
| 742 | + /// <returns></returns> | ||
| 743 | + public ILayer ReLU6() | ||
| 744 | + => new ReLu6(); | ||
| 745 | + | ||
| 746 | + | ||
| 738 | 747 | public IRnnCell SimpleRNNCell( | |
| 739 | 748 | int units, | |
| 740 | 749 | string activation = "tanh", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments