Browse Source

Merge pull request #490 from deepakkumar1984/master

Metrics and loss methods skeletonized
tags/v0.20
Deepak Kumar Battini GitHub 5 years ago
parent
commit
c5abf75932
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 1032 additions and 73 deletions
  1. +10
    -0
      TensorFlow.NET.sln
  2. +29
    -0
      src/TensorFlowNET.Keras/Args.cs
  3. +1
    -1
      src/TensorFlowNET.Keras/Engine/CallContext.cs
  4. +1
    -1
      src/TensorFlowNET.Keras/Engine/Node.cs
  5. +0
    -10
      src/TensorFlowNET.Keras/Engine/Saving.cs
  6. +2
    -1
      src/TensorFlowNET.Keras/Engine/Sequential.cs
  7. +43
    -0
      src/TensorFlowNET.Keras/KwArgs.cs
  8. +31
    -0
      src/TensorFlowNET.Keras/Losses/Loss.cs
  9. +32
    -1
      src/TensorFlowNET.Keras/Metrics/AUC.cs
  10. +5
    -1
      src/TensorFlowNET.Keras/Metrics/Accuracy.cs
  11. +10
    -1
      src/TensorFlowNET.Keras/Metrics/BinaryAccuracy.cs
  12. +10
    -1
      src/TensorFlowNET.Keras/Metrics/BinaryCrossentropy.cs
  13. +5
    -1
      src/TensorFlowNET.Keras/Metrics/CategoricalAccuracy.cs
  14. +10
    -1
      src/TensorFlowNET.Keras/Metrics/CategoricalCrossentropy.cs
  15. +5
    -1
      src/TensorFlowNET.Keras/Metrics/CategoricalHinge.cs
  16. +10
    -1
      src/TensorFlowNET.Keras/Metrics/CosineSimilarity.cs
  17. +5
    -1
      src/TensorFlowNET.Keras/Metrics/FalseNegatives.cs
  18. +5
    -1
      src/TensorFlowNET.Keras/Metrics/FalsePositives.cs
  19. +5
    -1
      src/TensorFlowNET.Keras/Metrics/Hinge.cs
  20. +5
    -1
      src/TensorFlowNET.Keras/Metrics/KLDivergence.cs
  21. +5
    -1
      src/TensorFlowNET.Keras/Metrics/LogCoshError.cs
  22. +6
    -1
      src/TensorFlowNET.Keras/Metrics/Mean.cs
  23. +5
    -1
      src/TensorFlowNET.Keras/Metrics/MeanAbsoluteError.cs
  24. +5
    -1
      src/TensorFlowNET.Keras/Metrics/MeanAbsolutePercentageError.cs
  25. +25
    -1
      src/TensorFlowNET.Keras/Metrics/MeanIoU.cs
  26. +16
    -1
      src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs
  27. +21
    -1
      src/TensorFlowNET.Keras/Metrics/MeanRelativeError.cs
  28. +5
    -1
      src/TensorFlowNET.Keras/Metrics/MeanSquaredError.cs
  29. +5
    -1
      src/TensorFlowNET.Keras/Metrics/MeanSquaredLogarithmicError.cs
  30. +38
    -1
      src/TensorFlowNET.Keras/Metrics/MeanTensor.cs
  31. +54
    -1
      src/TensorFlowNET.Keras/Metrics/Metric.cs
  32. +5
    -1
      src/TensorFlowNET.Keras/Metrics/Poisson.cs
  33. +32
    -1
      src/TensorFlowNET.Keras/Metrics/Precision.cs
  34. +16
    -1
      src/TensorFlowNET.Keras/Metrics/PrecisionAtRecall.cs
  35. +32
    -1
      src/TensorFlowNET.Keras/Metrics/Recall.cs
  36. +16
    -1
      src/TensorFlowNET.Keras/Metrics/Reduce.cs
  37. +5
    -1
      src/TensorFlowNET.Keras/Metrics/RootMeanSquaredError.cs
  38. +16
    -1
      src/TensorFlowNET.Keras/Metrics/SensitivityAtSpecificity.cs
  39. +20
    -1
      src/TensorFlowNET.Keras/Metrics/SensitivitySpecificityBase.cs
  40. +6
    -1
      src/TensorFlowNET.Keras/Metrics/SparseCategoricalAccuracy.cs
  41. +10
    -1
      src/TensorFlowNET.Keras/Metrics/SparseCategoricalCrossentropy.cs
  42. +11
    -1
      src/TensorFlowNET.Keras/Metrics/SparseTopKCategoricalAccuracy.cs
  43. +5
    -1
      src/TensorFlowNET.Keras/Metrics/SquaredHinge.cs
  44. +5
    -1
      src/TensorFlowNET.Keras/Metrics/Sum.cs
  45. +4
    -1
      src/TensorFlowNET.Keras/Metrics/SumOverBatchSize.cs
  46. +16
    -1
      src/TensorFlowNET.Keras/Metrics/SumOverBatchSizeMetricWrapper.cs
  47. +10
    -1
      src/TensorFlowNET.Keras/Metrics/TopKCategoricalAccuracy.cs
  48. +5
    -1
      src/TensorFlowNET.Keras/Metrics/TrueNegatives.cs
  49. +5
    -1
      src/TensorFlowNET.Keras/Metrics/TruePositives.cs
  50. +28
    -1
      src/TensorFlowNET.Keras/Metrics/_ConfusionMatrixConditionCount.cs
  51. +32
    -4
      src/TensorFlowNET.Keras/Models.cs
  52. +0
    -10
      src/TensorFlowNET.Keras/Ops.cs
  53. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/Adadelta.cs
  54. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/Adagrad.cs
  55. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/Adam.cs
  56. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/Adamax.cs
  57. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/Nadam.cs
  58. +36
    -0
      src/TensorFlowNET.Keras/Optimizer/Optimizer.cs
  59. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/RMSprop.cs
  60. +25
    -0
      src/TensorFlowNET.Keras/Optimizer/SGD.cs
  61. +1
    -1
      src/TensorFlowNET.Keras/OptimizersV2/OptimizerV2.cs
  62. +16
    -1
      src/TensorFlowNET.Keras/Regularizers/L1L2.cs
  63. +31
    -1
      src/TensorFlowNET.Keras/Regularizers/Regularizer.cs
  64. +51
    -1
      src/TensorFlowNET.Keras/Utils/MetricsUtils.cs
  65. +14
    -0
      test/Tensorflow.Keras.UnitTest/OptimizerTest.cs
  66. +20
    -0
      test/Tensorflow.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj

+ 10
- 0
TensorFlow.NET.sln View File

@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "test\TensorFlow
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Keras", "src\TensorFlowNET.Keras\Tensorflow.Keras.csproj", "{6268B461-486A-460B-9B3C-86493CBBAAF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tensorflow.Keras.UnitTest", "test\Tensorflow.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj", "{EB92DD90-6346-41FB-B967-2B33A860AD98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,14 @@ Global
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|Any CPU.Build.0 = Release|Any CPU
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.ActiveCfg = Release|Any CPU
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.Build.0 = Release|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.ActiveCfg = Debug|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.Build.0 = Debug|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.Build.0 = Release|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.ActiveCfg = Release|Any CPU
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 29
- 0
src/TensorFlowNET.Keras/Args.cs View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Args
{
private List<object> args = new List<object>();

public object this[int index]
{
get
{
return args.Count < index ? args[index] : null;
}
}

public T Get<T>(int index)
{
return args.Count < index ? (T)args[index] : default(T);
}

public void Add<T>(T arg)
{
args.Add(arg);
}
}
}

+ 1
- 1
src/TensorFlowNET.Keras/Engine/CallContext.cs View File

@@ -20,7 +20,7 @@ namespace Tensorflow.Keras.Engine

}

public void enter(Layer layer, Tensor[] inputs, Graph build_graph, bool training, Saving saving = null) => throw new NotImplementedException();
public void enter(Layer layer, Tensor[] inputs, Graph build_graph, bool training) => throw new NotImplementedException();

public bool training_arg_passed_to_call(string[] argspec, Dictionary<string, object> args, Dictionary<string, object> kwargs) => throw new NotImplementedException();



+ 1
- 1
src/TensorFlowNET.Keras/Engine/Node.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Engine
{
class Node
public class Node
{
}
}

+ 0
- 10
src/TensorFlowNET.Keras/Engine/Saving.cs View File

@@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Engine
{
public class Saving
{
}
}

+ 2
- 1
src/TensorFlowNET.Keras/Engine/Sequential.cs View File

@@ -4,7 +4,8 @@ using System.Text;

namespace Tensorflow.Keras.Engine
{
class Sequential
public class Sequential
{
}
}

+ 43
- 0
src/TensorFlowNET.Keras/KwArgs.cs View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class KwArgs
{
private Dictionary<string, object> args = new Dictionary<string, object>();

public object this[string name]
{
get
{
return args.ContainsKey(name) ? args[name] : null;
}
set
{
args[name] = value;
}
}

public T Get<T>(string name)
{
if (!args.ContainsKey(name))
return default(T);

return (T)args[name];
}

public static explicit operator KwArgs(ValueTuple<string, object>[] p)
{
KwArgs kwArgs = new KwArgs();
kwArgs.args = new Dictionary<string, object>();
foreach (var item in p)
{
kwArgs.args[item.Item1] = item.Item2;
}

return kwArgs;
}
}
}

+ 31
- 0
src/TensorFlowNET.Keras/Losses/Loss.cs View File

@@ -6,5 +6,36 @@ namespace Tensorflow.Keras.Losses
{
public abstract class Loss
{
public static Tensor mean_squared_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor mean_absolute_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor mean_absolute_percentage_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor mean_squared_logarithmic_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor _maybe_convert_labels(Tensor y_true) => throw new NotImplementedException();

public static Tensor squared_hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor categorical_hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor huber_loss(Tensor y_true, Tensor y_pred, float delta = 1) => throw new NotImplementedException();

public static Tensor logcosh(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor categorical_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float label_smoothing = 0) => throw new NotImplementedException();

public static Tensor sparse_categorical_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float axis = -1) => throw new NotImplementedException();

public static Tensor binary_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float label_smoothing = 0) => throw new NotImplementedException();

public static Tensor kullback_leibler_divergence(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor poisson(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor cosine_similarity(Tensor y_true, Tensor y_pred, int axis = -1) => throw new NotImplementedException();
}
}

+ 32
- 1
src/TensorFlowNET.Keras/Metrics/AUC.cs View File

@@ -1,10 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class AUC
public class AUC : Metric
{
public AUC(int num_thresholds= 200, string curve= "ROC", string summation_method= "interpolation",
string name= null, string dtype= null, float thresholds= 0.5f,
bool multi_label= false, Tensor label_weights= null) : base(name, dtype)
{
throw new NotImplementedException();
}

private void _build(TensorShape shape) => throw new NotImplementedException();

public Tensor interpolate_pr_auc() => throw new NotImplementedException();

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override void reset_states()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/Accuracy.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Accuracy
public class Accuracy : MeanMetricWrapper
{
public Accuracy(string name = "accuracy", string dtype = null)
: base(Metric.accuracy, name, dtype)
{
}
}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/BinaryAccuracy.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class BinaryAccuracy
public class BinaryAccuracy : MeanMetricWrapper
{
public BinaryAccuracy(string name = "binary_accuracy", string dtype = null, float threshold = 0.5f)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Metric.binary_accuracy(y_true, y_pred);
}
}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/BinaryCrossentropy.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class BinaryCrossentropy
public class BinaryCrossentropy : MeanMetricWrapper
{
public BinaryCrossentropy(string name = "binary_crossentropy", string dtype = null, bool from_logits = false, float label_smoothing = 0)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Losses.Loss.binary_crossentropy(y_true, y_pred);
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/CategoricalAccuracy.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class CategoricalAccuracy
public class CategoricalAccuracy : MeanMetricWrapper
{
public CategoricalAccuracy(string name = "categorical_accuracy", string dtype = null)
: base(Metric.categorical_accuracy, name, dtype)
{
}
}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/CategoricalCrossentropy.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class CategoricalCrossentropy
public class CategoricalCrossentropy : MeanMetricWrapper
{
public CategoricalCrossentropy(string name = "categorical_crossentropy", string dtype = null, bool from_logits = false, float label_smoothing = 0)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Losses.Loss.categorical_crossentropy(y_true, y_pred);
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/CategoricalHinge.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class CategoricalHinge
public class CategoricalHinge : MeanMetricWrapper
{
public CategoricalHinge(string name = "categorical_hinge", string dtype = null)
: base(Losses.Loss.categorical_hinge, name, dtype)
{
}
}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/CosineSimilarity.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class CosineSimilarity
public class CosineSimilarity : MeanMetricWrapper
{
public CosineSimilarity(string name = "cosine_similarity", string dtype = null, int axis = -1)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Metric.cosine_proximity(y_true, y_pred);
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/FalseNegatives.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class FalseNegatives
public class FalseNegatives : _ConfusionMatrixConditionCount
{
public FalseNegatives(float thresholds = 0.5F, string name = null, string dtype = null)
: base(Utils.MetricsUtils.ConfusionMatrix.FALSE_NEGATIVES, thresholds, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/FalsePositives.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class FalsePositives
public class FalsePositives : _ConfusionMatrixConditionCount
{
public FalsePositives(float thresholds = 0.5F, string name = null, string dtype = null)
: base(Utils.MetricsUtils.ConfusionMatrix.FALSE_POSITIVES, thresholds, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/Hinge.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Hinge
public class Hinge : MeanMetricWrapper
{
public Hinge(string name = "hinge", string dtype = null)
: base(Losses.Loss.hinge, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/KLDivergence.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class KLDivergence
public class KLDivergence : MeanMetricWrapper
{
public KLDivergence(string name = "kullback_leibler_divergence", string dtype = null)
: base(Losses.Loss.logcosh, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/LogCoshError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class LogCoshError
public class LogCoshError : MeanMetricWrapper
{
public LogCoshError(string name = "logcosh", string dtype = null)
: base(Losses.Loss.logcosh, name, dtype)
{
}
}
}

+ 6
- 1
src/TensorFlowNET.Keras/Metrics/Mean.cs View File

@@ -4,7 +4,12 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Mean
public class Mean : Reduce
{
public Mean(string name, string dtype = null)
: base(Reduction.MEAN, name, dtype)
{
}

}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/MeanAbsoluteError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanAbsoluteError
public class MeanAbsoluteError : MeanMetricWrapper
{
public MeanAbsoluteError(string name = "mean_absolute_error", string dtype = null)
: base(Losses.Loss.mean_absolute_error, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/MeanAbsolutePercentageError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanAbsolutePercentageError
public class MeanAbsolutePercentageError : MeanMetricWrapper
{
public MeanAbsolutePercentageError(string name = "mean_absolute_percentage_error", string dtype = null)
: base(Losses.Loss.mean_absolute_percentage_error, name, dtype)
{
}
}
}

+ 25
- 1
src/TensorFlowNET.Keras/Metrics/MeanIoU.cs View File

@@ -1,10 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanIoU
public class MeanIoU : Metric
{
public MeanIoU(int num_classes, string name, string dtype) : base(name, dtype)
{
}

public override void reset_states()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}
}
}

+ 16
- 1
src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs View File

@@ -1,10 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanMetricWrapper
public class MeanMetricWrapper : Mean
{
public MeanMetricWrapper(Func<Tensor, Tensor, Tensor> fn, string name, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 21
- 1
src/TensorFlowNET.Keras/Metrics/MeanRelativeError.cs View File

@@ -1,10 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanRelativeError
public class MeanRelativeError : Metric
{
public MeanRelativeError(Tensor normalizer, string name, string dtype) : base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/MeanSquaredError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanSquaredError
public class MeanSquaredError : MeanMetricWrapper
{
public MeanSquaredError(string name = "mean_squared_error", string dtype = null)
: base(Losses.Loss.mean_squared_error, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/MeanSquaredLogarithmicError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanSquaredLogarithmicError
public class MeanSquaredLogarithmicError : MeanMetricWrapper
{
public MeanSquaredLogarithmicError(string name = "mean_squared_logarithmic_error", string dtype = null)
: base(Losses.Loss.mean_squared_logarithmic_error, name, dtype)
{
}
}
}

+ 38
- 1
src/TensorFlowNET.Keras/Metrics/MeanTensor.cs View File

@@ -4,7 +4,44 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class MeanTensor
public class MeanTensor : Metric
{
public int total
{
get
{
throw new NotImplementedException();
}
}

public int count
{
get
{
throw new NotImplementedException();
}
}

public MeanTensor(int num_classes, string name = "mean_tensor", string dtype = null) : base(name, dtype)
{
}


private void _build(TensorShape shape) => throw new NotImplementedException();

public override void reset_states()
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}
}
}

+ 54
- 1
src/TensorFlowNET.Keras/Metrics/Metric.cs View File

@@ -1,10 +1,63 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
public abstract class Metric
public abstract class Metric : Layers.Layer
{
public string dtype
{
get
{
throw new NotImplementedException();
}
}

public Metric(string name, string dtype)
{
throw new NotImplementedException();
}

public void __new__ (Metric cls, Args args, KwArgs kwargs) => throw new NotImplementedException();

public Tensor __call__(Metric cls, Args args, KwArgs kwargs) => throw new NotImplementedException();

public virtual Hashtable get_config() => throw new NotImplementedException();

public virtual void reset_states() => throw new NotImplementedException();

public abstract void update_state(Args args, KwArgs kwargs);

public abstract Tensor result();

public void add_weight(string name, TensorShape shape= null, VariableAggregation aggregation= VariableAggregation.Sum,
VariableSynchronization synchronization = VariableSynchronization.OnRead, Initializers.Initializer initializer= null,
string dtype= null) => throw new NotImplementedException();

public static Tensor accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor binary_accuracy(Tensor y_true, Tensor y_pred, float threshold = 0.5f) => throw new NotImplementedException();

public static Tensor categorical_accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor sparse_categorical_accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();

public static Tensor top_k_categorical_accuracy(Tensor y_true, Tensor y_pred, int k = 5) => throw new NotImplementedException();

public static Tensor sparse_top_k_categorical_accuracy(Tensor y_true, Tensor y_pred, int k = 5) => throw new NotImplementedException();

public static Tensor cosine_proximity(Tensor y_true, Tensor y_pred, int axis = -1) => throw new NotImplementedException();

public static Metric clone_metric(Metric metric) => throw new NotImplementedException();

public static Metric[] clone_metrics(Metric[] metric) => throw new NotImplementedException();

public static string serialize(Metric metric) => throw new NotImplementedException();

public static Metric deserialize(string config, object custom_objects = null) => throw new NotImplementedException();

public static Metric get(object identifier) => throw new NotImplementedException();
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/Poisson.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Poisson
public class Poisson : MeanMetricWrapper
{
public Poisson(string name = "logcosh", string dtype = null)
: base(Losses.Loss.logcosh, name, dtype)
{
}
}
}

+ 32
- 1
src/TensorFlowNET.Keras/Metrics/Precision.cs View File

@@ -1,10 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Precision
public class Precision : Metric
{
public Precision(float? thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public Precision(float[] thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override void reset_states()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}

}
}

+ 16
- 1
src/TensorFlowNET.Keras/Metrics/PrecisionAtRecall.cs View File

@@ -1,10 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class PrecisionAtRecall
public class PrecisionAtRecall : SensitivitySpecificityBase
{
public PrecisionAtRecall(float recall, int num_thresholds = 200, string name = null, string dtype = null) : base(recall, num_thresholds, name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 32
- 1
src/TensorFlowNET.Keras/Metrics/Recall.cs View File

@@ -1,10 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Recall
public class Recall : Metric
{
public Recall(float? thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public Recall(float[] thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override void reset_states()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}

}
}

+ 16
- 1
src/TensorFlowNET.Keras/Metrics/Reduce.cs View File

@@ -4,7 +4,22 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Reduce
public class Reduce : Metric
{
public Reduce(string reduction, string name, string dtype= null)
: base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/RootMeanSquaredError.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class RootMeanSquaredError
public class RootMeanSquaredError : Mean
{
public RootMeanSquaredError(string name = "root_mean_squared_error", string dtype = null)
: base(name, dtype)
{
}
}
}

+ 16
- 1
src/TensorFlowNET.Keras/Metrics/SensitivityAtSpecificity.cs View File

@@ -1,10 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SensitivityAtSpecificity
public class SensitivityAtSpecificity : SensitivitySpecificityBase
{
public SensitivityAtSpecificity(float specificity, int num_thresholds = 200, string name = null, string dtype = null) : base(specificity, num_thresholds, name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 20
- 1
src/TensorFlowNET.Keras/Metrics/SensitivitySpecificityBase.cs View File

@@ -4,7 +4,26 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SensitivitySpecificityBase
public class SensitivitySpecificityBase : Metric
{
public SensitivitySpecificityBase(float value, int num_thresholds= 200, string name = null, string dtype = null) : base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override void reset_states()
{
throw new NotImplementedException();
}
}
}

+ 6
- 1
src/TensorFlowNET.Keras/Metrics/SparseCategoricalAccuracy.cs View File

@@ -4,7 +4,12 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SparseCategoricalAccuracy
public class SparseCategoricalAccuracy : MeanMetricWrapper
{
public SparseCategoricalAccuracy(string name = "sparse_categorical_accuracy", string dtype = null)
: base(Metric.sparse_categorical_accuracy, name, dtype)
{
}

}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/SparseCategoricalCrossentropy.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SparseCategoricalCrossentropy
public class SparseCategoricalCrossentropy : MeanMetricWrapper
{
public SparseCategoricalCrossentropy(string name = "sparse_categorical_crossentropy", string dtype = null, bool from_logits = false, int axis = -1)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Losses.Loss.sparse_categorical_crossentropy(y_true, y_pred);
}
}
}

+ 11
- 1
src/TensorFlowNET.Keras/Metrics/SparseTopKCategoricalAccuracy.cs View File

@@ -4,7 +4,17 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SparseTopKCategoricalAccuracy
public class SparseTopKCategoricalAccuracy : MeanMetricWrapper
{
public SparseTopKCategoricalAccuracy(int k = 5, string name = "sparse_top_k_categorical_accuracy", string dtype = null)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Metric.sparse_top_k_categorical_accuracy(y_true, y_pred);
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/SquaredHinge.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SquaredHinge
public class SquaredHinge : MeanMetricWrapper
{
public SquaredHinge(string name = "squared_hinge", string dtype = null)
: base(Losses.Loss.squared_hinge, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/Sum.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Sum
public class Sum : Reduce
{
public Sum(string name, string dtype = null)
: base(Reduction.SUM, name, dtype)
{
}
}
}

+ 4
- 1
src/TensorFlowNET.Keras/Metrics/SumOverBatchSize.cs View File

@@ -4,7 +4,10 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SumOverBatchSize
public class SumOverBatchSize : Reduce
{
public SumOverBatchSize(string name = "sum_over_batch_size", string dtype = null) : base(Reduction.SUM_OVER_BATCH_SIZE, name, dtype)
{
}
}
}

+ 16
- 1
src/TensorFlowNET.Keras/Metrics/SumOverBatchSizeMetricWrapper.cs View File

@@ -1,10 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Metrics
{
class SumOverBatchSizeMetricWrapper
public class SumOverBatchSizeMetricWrapper : SumOverBatchSize
{
public SumOverBatchSizeMetricWrapper(Func<Tensor, Tensor, Tensor> fn, string name, string dtype = null)
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 10
- 1
src/TensorFlowNET.Keras/Metrics/TopKCategoricalAccuracy.cs View File

@@ -4,7 +4,16 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class TopKCategoricalAccuracy
public class TopKCategoricalAccuracy : MeanMetricWrapper
{
public TopKCategoricalAccuracy(int k = 5, string name = "top_k_categorical_accuracy", string dtype = null)
: base(Fn, name, dtype)
{
}

internal static Tensor Fn(Tensor y_true, Tensor y_pred)
{
return Metric.top_k_categorical_accuracy(y_true, y_pred);
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/TrueNegatives.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class TrueNegatives
public class TrueNegatives : _ConfusionMatrixConditionCount
{
public TrueNegatives(float thresholds = 0.5F, string name = null, string dtype = null)
: base(Utils.MetricsUtils.ConfusionMatrix.TRUE_NEGATIVES, thresholds, name, dtype)
{
}
}
}

+ 5
- 1
src/TensorFlowNET.Keras/Metrics/TruePositives.cs View File

@@ -4,7 +4,11 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class TruePositives
public class TruePositives : _ConfusionMatrixConditionCount
{
public TruePositives(float thresholds = 0.5F, string name = null, string dtype = null)
: base(Utils.MetricsUtils.ConfusionMatrix.TRUE_POSITIVES, thresholds, name, dtype)
{
}
}
}

+ 28
- 1
src/TensorFlowNET.Keras/Metrics/_ConfusionMatrixConditionCount.cs View File

@@ -1,10 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static Tensorflow.Keras.Utils.MetricsUtils;

namespace Tensorflow.Keras.Metrics
{
class _ConfusionMatrixConditionCount
public class _ConfusionMatrixConditionCount : Metric
{
public _ConfusionMatrixConditionCount(string confusion_matrix_cond, float thresholds= 0.5f, string name= null, string dtype= null)
: base(name, dtype)
{
throw new NotImplementedException();
}

public override Tensor result()
{
throw new NotImplementedException();
}

public override void update_state(Args args, KwArgs kwargs)
{
throw new NotImplementedException();
}

public override void reset_states()
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 32
- 4
src/TensorFlowNET.Keras/Models.cs View File

@@ -1,14 +1,42 @@
using System;
using Keras.Layers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Keras.Engine;

namespace Tensorflow.Keras
{
class Models
{
public class Model : Keras.Engine.Training.Model
{
public class Model : Keras.Engine.Training.Model{}

}
public static Layer share_weights(Layer layer) => throw new NotImplementedException();

private static Layer _clone_layer(Layer layer) => throw new NotImplementedException();

private static Layer _insert_ancillary_layers(Model model, Layer ancillary_layers, string[] metrics_names, Node[] new_nodes) => throw new NotImplementedException();

private static Node[] _make_new_nodes(Node[] nodes_by_depth, Func<Layer, Layer> layer_fn, Hashtable layer_map, Hashtable tensor_map) => throw new NotImplementedException();

private static Model _clone_functional_model(Model model, Tensor[] input_tensors = null, Func<Layer, Layer> layer_fn = null) => throw new NotImplementedException();

private static (Hashtable, Layer[]) _clone_layers_and_model_config(Model model, Layer[] input_layers, Func<Layer, Layer> layer_fn) => throw new NotImplementedException();

private static (Layer[], Layer[]) _remove_ancillary_layers(Model model, Hashtable layer_map, Layer[] layers) => throw new NotImplementedException();

private static Sequential _clone_sequential_model(Model model, Tensor[] input_tensors = null, Func<Layer, Layer> layer_fn = null) => throw new NotImplementedException();

public static Model clone_model(Model model, Tensor[] input_tensors = null, Func<Layer, Layer> layer_fn = null) => throw new NotImplementedException();

private static void _in_place_subclassed_model_reset(Model model) => throw new NotImplementedException();

private static void _reset_build_compile_trackers(Model model) => throw new NotImplementedException();

public static void in_place_subclassed_model_state_restoration(Model model) => throw new NotImplementedException();

public static void clone_and_build_model(Model model, Tensor[] input_tensors= null, Tensor[] target_tensors= null, object custom_objects= null,
bool compile_clone= true, bool in_place_reset= false, VariableV1 optimizer_iterations= null, Hashtable optimizer_config= null)
=> throw new NotImplementedException();
}
}

+ 0
- 10
src/TensorFlowNET.Keras/Ops.cs View File

@@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
class Ops
{
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/Adadelta.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Adadelta : Optimizer
{
public Adadelta(float lr= 0.01f, float rho = 0.95f, float? epsilon = null, float decay = 0) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/Adagrad.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Adagrad : Optimizer
{
public Adagrad(float lr= 0.01f, float? epsilon = null, float decay = 0) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/Adam.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Adam : Optimizer
{
public Adam(float lr= 0.001f, float beta_1 = 0.9f, float beta_2 = 0.99f, float? epsilon = null, float decay = 0) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/Adamax.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Adamax : Optimizer
{
public Adamax(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float decay = 0) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/Nadam.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Nadam : Optimizer
{
public Nadam(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float schedule_decay = 0.004f) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 36
- 0
src/TensorFlowNET.Keras/Optimizer/Optimizer.cs View File

@@ -0,0 +1,36 @@
using NumSharp;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class Optimizer
{
public Optimizer(KwArgs kwargs)
{
throw new NotImplementedException();
}

public virtual Tensor[] get_updates(Tensor loss, variables @params)
{
return null;
}

public virtual Tensor[] get_gradients(Tensor loss, variables @params) => throw new NotImplementedException();

public virtual void set_weights(NDArray[] weights) => throw new NotImplementedException();

public virtual NDArray[] get_weights() => throw new NotImplementedException();

public virtual Hashtable get_config() => throw new NotImplementedException();

public static string serialize(Optimizer optimizer) => throw new NotImplementedException();

public static Optimizer deserialize(string config, object custom_objects = null) => throw new NotImplementedException();

public static Optimizer get(object identifier) => throw new NotImplementedException();

}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/RMSprop.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class RMSprop : Optimizer
{
public RMSprop(float lr= 0.01f, float rho = 0f, float? epsilon = null, float decay = 0) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 25
- 0
src/TensorFlowNET.Keras/Optimizer/SGD.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras
{
public class SGD : Optimizer
{
public SGD(float lr= 0.01f, float momentum= 0, float decay= 0, bool nesterov= false) : base(null)
{
throw new NotImplementedException();
}

public override Tensor[] get_updates(Tensor loss, variables @params)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

src/TensorFlowNET.Keras/OptimizersV2/BaseOptimizerV2.cs → src/TensorFlowNET.Keras/OptimizersV2/OptimizerV2.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.OptimizersV2
{
class BaseOptimizerV2
class OptimizerV2
{
}
}

+ 16
- 1
src/TensorFlowNET.Keras/Regularizers/L1L2.cs View File

@@ -1,10 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Regularizers
{
class L1L2
public class L1L2 : Regularizer
{
public L1L2(float l1 = 0f, float l2 = 0f)
{
throw new NotImplementedException();
}

public override float call(Tensor x)
{
throw new NotImplementedException();
}

public override Hashtable get_config()
{
throw new NotImplementedException();
}
}
}

+ 31
- 1
src/TensorFlowNET.Keras/Regularizers/Regularizer.cs View File

@@ -1,10 +1,40 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Regularizers
{
public class Regularizer
public abstract class Regularizer
{
public virtual float call(Tensor x)
{
return 0f;
}

public static Regularizer from_config(Hashtable hashtable) => throw new NotImplementedException();

public virtual Hashtable get_config() => throw new NotImplementedException();

public static Regularizer l1(float l = 0.01f)
{
return new L1L2(l1: l);
}

public static Regularizer l2(float l = 0.01f)
{
return new L1L2(l2: l);
}

public static Regularizer l1_l2(float l1 = 0.01f, float l2 = 0.01f)
{
return new L1L2(l1, l2);
}

public static string serialize(Regularizer regularizer) => throw new NotImplementedException();

public static string deserialize(string config, dynamic custom_objects = null) => throw new NotImplementedException();

public static Regularizer get(object identifier) => throw new NotImplementedException();
}
}

+ 51
- 1
src/TensorFlowNET.Keras/Utils/MetricsUtils.cs View File

@@ -1,10 +1,60 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Tensorflow.Keras.Utils
{
class MetricsUtils
public class MetricsUtils
{
public static class Reduction
{
public const string SUM = "sum";
public const string SUM_OVER_BATCH_SIZE = "sum_over_batch_size";
public const string WEIGHTED_MEAN = "weighted_mean";
}

public static class ConfusionMatrix
{
public const string TRUE_POSITIVES = "tp";
public const string FALSE_POSITIVES = "fp";
public const string TRUE_NEGATIVES = "tn";
public const string FALSE_NEGATIVES = "fn";
}

public static class AUCCurve
{
public const string ROC = "ROC";
public const string PR = "PR";

public static string from_str(string key) => throw new NotImplementedException();
}

public static class AUCSummationMethod
{
public const string INTERPOLATION = "interpolation";
public const string MAJORING = "majoring";
public const string MINORING = "minoring";

public static string from_str(string key) => throw new NotImplementedException();
}

public static dynamic update_state_wrapper(Func<Args, KwArgs, Func<bool>> update_state_fn) => throw new NotImplementedException();

public static dynamic result_wrapper(Func<Args, Tensor> result_fn) => throw new NotImplementedException();

public static WeakReference weakmethod(MethodInfo method) => throw new NotImplementedException();

public static void assert_thresholds_range(float[] thresholds) => throw new NotImplementedException();

public static void parse_init_thresholds(float[] thresholds, float default_threshold = 0.5f) => throw new NotImplementedException();

public static Operation update_confusion_matrix_variables(variables variables_to_update, Tensor y_true, Tensor y_pred, float[] thresholds,
int? top_k= null,int? class_id= null, Tensor sample_weight= null, bool multi_label= false,
Tensor label_weights= null) => throw new NotImplementedException();

private static Tensor _filter_top_k(Tensor x, int k) => throw new NotImplementedException();

private static (Tensor[], Tensor) ragged_assert_compatible_and_get_flat_values(Tensor[] values, Tensor mask = null) => throw new NotImplementedException();
}
}

+ 14
- 0
test/Tensorflow.Keras.UnitTest/OptimizerTest.cs View File

@@ -0,0 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace Tensorflow.Keras.UnitTest
{
[TestClass]
public class OptimizerTest
{
[TestMethod]
public void BaseConstruct()
{
}
}
}

+ 20
- 0
test/Tensorflow.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Keras\Tensorflow.Keras.csproj" />
</ItemGroup>

</Project>

Loading…
Cancel
Save