Skip to content

Commit f566505

Browse files
HallupaOceania2018
authored andcommitted
Add Softmax support and throw exception if activation isn't found
1 parent f980266 commit f566505

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using static Tensorflow.Binding;
3+
4+
namespace Tensorflow.Keras
5+
{
6+
public partial class Activations
7+
{
8+
public Activation Softmax = (features, name)
9+
=> tf.Context.ExecuteOp("Softmax", name, new ExecuteOpArgs(features));
10+
}
11+
}

src/TensorFlowNET.Keras/Layers/LayersApi.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Tensorflow.NumPy;
1+
using System;
2+
using Tensorflow.NumPy;
23
using System.Collections.Generic;
34
using Tensorflow.Keras.ArgsDefinition;
45
using Tensorflow.Keras.Engine;
@@ -834,7 +835,8 @@ Activation GetActivationByName(string name)
834835
"relu" => keras.activations.Relu,
835836
"sigmoid" => keras.activations.Sigmoid,
836837
"tanh" => keras.activations.Tanh,
837-
_ => keras.activations.Linear
838+
"softmax" => keras.activations.Softmax,
839+
_ => throw new Exception($"Activation {name} not found")
838840
};
839841

840842
/// <summary>

0 commit comments

Comments
 (0)