Browse Source

add EstimatorV2 and IEstimator.

tags/v0.9
Oceania2018 6 years ago
parent
commit
09266546bf
11 changed files with 180 additions and 3 deletions
  1. +1
    -1
      src/TensorFlowNET.Core/APIs/tf.io.cs
  2. +10
    -0
      src/TensorFlowNET.Core/Data/DatasetV1.cs
  3. +13
    -0
      src/TensorFlowNET.Core/Data/DatasetV1Adapter.cs
  4. +19
    -0
      src/TensorFlowNET.Core/Data/DatasetV2.cs
  5. +38
    -0
      src/TensorFlowNET.Core/Estimator/EstimatorV2.cs
  6. +27
    -0
      src/TensorFlowNET.Core/Estimator/HyperParams.cs
  7. +11
    -0
      src/TensorFlowNET.Core/Estimator/IEstimator.cs
  8. +6
    -0
      src/TensorFlowNET.Core/Estimator/README.md
  9. +19
    -0
      src/TensorFlowNET.Core/Estimator/TrainingExecutor.cs
  10. +2
    -2
      test/TensorFlowNET.Examples/Text/NER/BiLstmCrfNer.cs
  11. +34
    -0
      test/TensorFlowNET.Examples/Text/NER/CRF.cs

+ 1
- 1
src/TensorFlowNET.Core/APIs/tf.io.cs View File

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


namespace Tensorflow namespace Tensorflow
{ {
public partial class tf
public static partial class tf
{ {
public static Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); public static Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name);




+ 10
- 0
src/TensorFlowNET.Core/Data/DatasetV1.cs View File

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

namespace Tensorflow.Data
{
public class DatasetV1 : DatasetV2
{
}
}

+ 13
- 0
src/TensorFlowNET.Core/Data/DatasetV1Adapter.cs View File

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

namespace Tensorflow.Data
{
/// <summary>
/// Wraps a V2 `Dataset` object in the `tf.compat.v1.data.Dataset` API.
/// </summary>
public class DatasetV1Adapter : DatasetV1
{
}
}

+ 19
- 0
src/TensorFlowNET.Core/Data/DatasetV2.cs View File

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

namespace Tensorflow.Data
{
/// <summary>
/// Represents a potentially large set of elements.
///
/// A `Dataset` can be used to represent an input pipeline as a
/// collection of elements (nested structures of tensors) and a "logical
/// plan" of transformations that act on those elements.
///
/// tensorflow\python\data\ops\dataset_ops.py
/// </summary>
public class DatasetV2
{
}
}

+ 38
- 0
src/TensorFlowNET.Core/Estimator/EstimatorV2.cs View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Data;

namespace Tensorflow.Estimator
{
/// <summary>
/// Estimator class to train and evaluate TensorFlow models.
/// <see cref="tensorflow_estimator\python\estimator\estimator.py"/>
/// </summary>
public class EstimatorV2 : IEstimator
{
public EstimatorV2(string model_dir = null)
{

}

/// <summary>
/// Calls the input function.
/// </summary>
/// <param name="mode"></param>
public void call_input_fn(string mode = null)
{

}

public void train_model_default(Func<string, string, HyperParams, bool, DatasetV1Adapter> input_fn)
{

}

public void get_features_and_labels_from_input_fn()
{

}
}
}

+ 27
- 0
src/TensorFlowNET.Core/Estimator/HyperParams.cs View File

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

namespace Tensorflow.Estimator
{
public class HyperParams
{
public string data_dir { get; set; }
public string result_dir { get; set; }
public string model_dir { get; set; }
public string eval_dir { get; set; }

public int dim { get; set; } = 300;
public float dropout { get; set; } = 0.5f;
public int num_oov_buckets { get; set; } = 1;
public int epochs { get; set; } = 25;
public int batch_size { get; set; } = 20;
public int buffer { get; set; } = 15000;
public int lstm_size { get; set; } = 100;

public string words { get; set; }
public string chars { get; set; }
public string tags { get; set; }
public string glove { get; set; }
}
}

+ 11
- 0
src/TensorFlowNET.Core/Estimator/IEstimator.cs View File

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

namespace Tensorflow.Estimator
{
public interface IEstimator
{

}
}

+ 6
- 0
src/TensorFlowNET.Core/Estimator/README.md View File

@@ -0,0 +1,6 @@
### TensorFlow Estimator

TensorFlow Estimator is a high-level TensorFlow API that greatly simplifies machine learning programming. Estimators encapsulate training, evaluation, prediction, and exporting for your model.

Guide: <https://www.tensorflow.org/guide/estimators>


+ 19
- 0
src/TensorFlowNET.Core/Estimator/TrainingExecutor.cs View File

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

namespace Tensorflow.Estimator
{
/// <summary>
/// The executor to run `Estimator` training and evaluation.
/// <see cref="tensorflow_estimator\python\estimator\training.py"/>
/// </summary>
public class TrainingExecutor : Python
{
private IEstimator _estimator;
public TrainingExecutor(IEstimator estimator)
{
_estimator = estimator;
}
}
}

+ 2
- 2
test/TensorFlowNET.Examples/Text/NER/BiLstmCrfNer.cs View File

@@ -13,7 +13,7 @@ namespace TensorFlowNET.Examples
/// </summary> /// </summary>
public class BiLstmCrfNer : IExample public class BiLstmCrfNer : IExample
{ {
public int Priority => 13;
public int Priority => 101;


public bool Enabled { get; set; } = true; public bool Enabled { get; set; } = true;
public bool ImportGraph { get; set; } = false; public bool ImportGraph { get; set; } = false;
@@ -24,7 +24,7 @@ namespace TensorFlowNET.Examples
public bool Run() public bool Run()
{ {
PrepareData(); PrepareData();
return true;
return false;
} }


public void PrepareData() public void PrepareData()


+ 34
- 0
test/TensorFlowNET.Examples/Text/NER/CRF.cs View File

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

namespace TensorFlowNET.Examples
{
/// <summary>
/// The CRF module implements a linear-chain CRF layer for learning to predict tag sequences.
/// This variant of the CRF is factored into unary potentials for every element
/// in the sequence and binary potentials for every transition between output tags.
///
/// tensorflow\contrib\crf\python\ops\crf.py
/// </summary>
public class CRF : Python, IExample
{
public int Priority => 13;

public bool Enabled { get; set; } = true;
public bool ImportGraph { get; set; } = false;

public string Name => "CRF";

public bool Run()
{
return true;
}

public void PrepareData()
{

}
}
}

Loading…
Cancel
Save