From 508698d7b209a461e1e6b4c711bded3152cd24ae Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 17 May 2024 11:55:35 -0400 Subject: [PATCH] RegularizerAPI --- .../Keras/Regularizers/IRegularizer.cs | 10 +++++++++- src/TensorFlowNET.Keras/Regularizers.cs | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs b/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs index e5de76dd..2be231c8 100644 --- a/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs +++ b/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs @@ -12,5 +12,13 @@ namespace Tensorflow.Keras [JsonProperty("config")] IDictionary Config { get; } Tensor Apply(RegularizerArgs args); - } + } + + public interface IRegularizerApi + { + IRegularizer L1 { get; } + IRegularizer L2 { get; } + IRegularizer L1L2 { get; } + } + } diff --git a/src/TensorFlowNET.Keras/Regularizers.cs b/src/TensorFlowNET.Keras/Regularizers.cs index 9c6d07ca..402eedd5 100644 --- a/src/TensorFlowNET.Keras/Regularizers.cs +++ b/src/TensorFlowNET.Keras/Regularizers.cs @@ -1,6 +1,6 @@ namespace Tensorflow.Keras { - public class Regularizers + public class Regularizers: IRegularizerApi { public IRegularizer l1(float l1 = 0.01f) => new Tensorflow.Operations.Regularizers.L1(l1); @@ -13,5 +13,11 @@ //# and no l1 penalty. public IRegularizer l1l2(float l1 = 0.00f, float l2 = 0.00f) => new Tensorflow.Operations.Regularizers.L1L2(l1, l2); + + public IRegularizer L1 => l1(); + + public IRegularizer L2 => l2(); + + public IRegularizer L1L2 => l1l2(); } }