Browse Source

Add Softmax support and throw exception if activation isn't found

tags/v0.60-tf.numpy
Hallupa Haiping 4 years ago
parent
commit
f566505c09
2 changed files with 15 additions and 2 deletions
  1. +11
    -0
      src/TensorFlowNET.Keras/Activations/Activations.Softmax.cs
  2. +4
    -2
      src/TensorFlowNET.Keras/Layers/LayersApi.cs

+ 11
- 0
src/TensorFlowNET.Keras/Activations/Activations.Softmax.cs View File

@@ -0,0 +1,11 @@
using System;
using static Tensorflow.Binding;

namespace Tensorflow.Keras
{
public partial class Activations
{
public Activation Softmax = (features, name)
=> tf.Context.ExecuteOp("Softmax", name, new ExecuteOpArgs(features));
}
}

+ 4
- 2
src/TensorFlowNET.Keras/Layers/LayersApi.cs View File

@@ -1,4 +1,5 @@
using Tensorflow.NumPy;
using System;
using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
@@ -834,7 +835,8 @@ namespace Tensorflow.Keras.Layers
"relu" => keras.activations.Relu,
"sigmoid" => keras.activations.Sigmoid,
"tanh" => keras.activations.Tanh,
_ => keras.activations.Linear
"softmax" => keras.activations.Softmax,
_ => throw new Exception($"Activation {name} not found")
};

/// <summary>


Loading…
Cancel
Save