diff --git a/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj b/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
index 05c2730e..ebbefb44 100644
--- a/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
+++ b/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
@@ -18,7 +18,12 @@
Google's TensorFlow full binding in .NET Standard.
Docs: https://tensorflownet.readthedocs.io
0.11.0.0
- Changes since v0.10.0:
+ Changes since v0.10.0:
+1. Upgrade NumSharp to v0.20.
+2. Add DisposableObject class to manage object lifetime.
+3. Add tf.no_op, tf.nn.in_top_k, tf.GraphKeys and tf.trainable_variables.
+4. Change tensorflow to non-static class in order to execute some initialization process.
+5. Overloade session.run(), make syntax simpler.
7.3
0.11.0.0
LICENSE
diff --git a/src/TensorFlowNET.Core/Variables/RefVariable.cs b/src/TensorFlowNET.Core/Variables/RefVariable.cs
index 3f9e8acf..eb0f7316 100644
--- a/src/TensorFlowNET.Core/Variables/RefVariable.cs
+++ b/src/TensorFlowNET.Core/Variables/RefVariable.cs
@@ -158,7 +158,7 @@ namespace Tensorflow
// Or get the initial value from a Tensor or Python object.
else
{
- _initial_value = ops.convert_to_tensor(initial_value, name: "initial_value");
+ _initial_value = ops.convert_to_tensor(initial_value, name: "initial_value", dtype: dtype);
var shape = _initial_value.shape;
dtype = _initial_value.dtype;
diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs
index b2945f13..e485ba6f 100644
--- a/src/TensorFlowNET.Core/ops.cs
+++ b/src/TensorFlowNET.Core/ops.cs
@@ -488,6 +488,8 @@ namespace Tensorflow
switch (value)
{
+ case String str:
+ return constant_op.constant(str, dtype: TF_DataType.TF_STRING, name: name);
case NDArray nd:
return constant_op.constant(nd, dtype: dtype, name: name);
case Tensor tensor:
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Dataset.cs b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Dataset.cs
new file mode 100644
index 00000000..3277e67e
--- /dev/null
+++ b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Dataset.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TensorFlowNET.Examples.ImageProcessing.YOLO
+{
+ public class Dataset
+ {
+ string annot_path;
+ public int Length = 0;
+
+ public Dataset(string dataset_type, Config cfg)
+ {
+ annot_path = dataset_type == "train" ? cfg.TRAIN.ANNOT_PATH : cfg.TEST.ANNOT_PATH;
+ }
+ }
+}
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Main.cs b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Main.cs
index 8a88225a..15f162b8 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Main.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/Main.cs
@@ -13,13 +13,26 @@ namespace TensorFlowNET.Examples.ImageProcessing.YOLO
///
public class Main : IExample
{
- public bool Enabled { get; set; } = true;
+ public bool Enabled { get; set; } = false;
public bool IsImportingGraph { get; set; } = false;
-
public string Name => "YOLOv3";
+ #region args
Dictionary classes;
- Config config;
+ int num_classes;
+ float learn_rate_init;
+ float learn_rate_end;
+ int first_stage_epochs;
+ int second_stage_epochs;
+ int warmup_periods;
+ string time;
+ float moving_ave_decay;
+ int max_bbox_per_scale;
+ int steps_per_period;
+
+ Dataset trainset, testset;
+
+ Config cfg;
Tensor input_data;
Tensor label_sbbox;
@@ -28,7 +41,8 @@ namespace TensorFlowNET.Examples.ImageProcessing.YOLO
Tensor true_sbboxes;
Tensor true_mbboxes;
Tensor true_lbboxes;
- Tensor trainable;
+ Tensor trainable;
+ #endregion
public bool Run()
{
@@ -90,14 +104,28 @@ namespace TensorFlowNET.Examples.ImageProcessing.YOLO
public void PrepareData()
{
- config = new Config(Name);
+ cfg = new Config(Name);
string dataDir = Path.Combine(Name, "data");
Directory.CreateDirectory(dataDir);
classes = new Dictionary();
- foreach (var line in File.ReadAllLines(config.CLASSES))
+ foreach (var line in File.ReadAllLines(cfg.YOLO.CLASSES))
classes[classes.Count] = line;
+ num_classes = classes.Count;
+
+ learn_rate_init = cfg.TRAIN.LEARN_RATE_INIT;
+ learn_rate_end = cfg.TRAIN.LEARN_RATE_END;
+ first_stage_epochs = cfg.TRAIN.FISRT_STAGE_EPOCHS;
+ second_stage_epochs = cfg.TRAIN.SECOND_STAGE_EPOCHS;
+ warmup_periods = cfg.TRAIN.WARMUP_EPOCHS;
+ DateTime now = DateTime.Now;
+ time = $"{now.Year}-{now.Month}-{now.Day}-{now.Hour}-{now.Minute}-{now.Minute}";
+ moving_ave_decay = cfg.YOLO.MOVING_AVE_DECAY;
+ max_bbox_per_scale = 150;
+ trainset = new Dataset("train", cfg);
+ testset = new Dataset("test", cfg);
+ steps_per_period = trainset.Length;
}
}
}
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/YOLO/config.cs b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/config.cs
index 3d9105ed..99bee6dc 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/YOLO/config.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/YOLO/config.cs
@@ -7,13 +7,52 @@ namespace TensorFlowNET.Examples.ImageProcessing.YOLO
{
public class Config
{
- string _root;
- public string CLASSES;
+ public YoloConfig YOLO;
+ public TrainConfig TRAIN;
+ public TrainConfig TEST;
public Config(string root)
{
- _root = root;
- CLASSES = Path.Combine(_root, "data", "classes", "coco.names");
+ YOLO = new YoloConfig(root);
+ TRAIN = new TrainConfig(root);
+ }
+
+ public class YoloConfig
+ {
+ string _root;
+
+ public string CLASSES;
+ public float MOVING_AVE_DECAY = 0.9995f;
+ public int[] STRIDES = new int[] { 8, 16, 32 };
+
+ public YoloConfig(string root)
+ {
+ _root = root;
+ CLASSES = Path.Combine(_root, "data", "classes", "coco.names");
+ }
+ }
+
+ public class TrainConfig
+ {
+ string _root;
+
+ public int BATCH_SIZE = 6;
+ public int[] INPUT_SIZE = new int[] { 320, 352, 384, 416, 448, 480, 512, 544, 576, 608 };
+ public bool DATA_AUG = true;
+ public float LEARN_RATE_INIT = 1e-4f;
+ public float LEARN_RATE_END = 1e-6f;
+ public int WARMUP_EPOCHS = 2;
+ public int FISRT_STAGE_EPOCHS = 20;
+ public int SECOND_STAGE_EPOCHS = 30;
+ public string INITIAL_WEIGHT;
+ public string ANNOT_PATH;
+
+ public TrainConfig(string root)
+ {
+ _root = root;
+ INITIAL_WEIGHT = Path.Combine(_root, "data", "checkpoint", "yolov3_coco_demo.ckpt");
+ ANNOT_PATH = Path.Combine(_root, "data", "dataset", "voc_train.txt");
+ }
}
}
}
diff --git a/test/TensorFlowNET.UnitTest/VariableTest.cs b/test/TensorFlowNET.UnitTest/VariableTest.cs
index 7673cac8..211d7b65 100644
--- a/test/TensorFlowNET.UnitTest/VariableTest.cs
+++ b/test/TensorFlowNET.UnitTest/VariableTest.cs
@@ -24,7 +24,7 @@ namespace TensorFlowNET.UnitTest
[TestMethod]
public void StringVar()
{
- var mammal1 = tf.Variable("Elephant", name: "var1", dtype: tf.chars);
+ var mammal1 = tf.Variable("Elephant", name: "var1", dtype: tf.@string);
var mammal2 = tf.Variable("Tiger");
}
diff --git a/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs b/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs
index 4e82a2b6..72dd83ea 100644
--- a/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs
+++ b/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs
@@ -11,6 +11,7 @@ namespace TensorFlowNET.UnitTest.control_flow_ops_test
///
/// https://www.tensorflow.org/api_docs/python/tf/while_loop
///
+ [Ignore]
[TestMethod]
public void SimpleWhileLoop()
{