Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/TensorFlowNET.Core/Train/AdamOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,12 @@ private Operation _apply_sparse_shared(Tensor grad, RefVariable var, Tensor indi
return (_get_non_slot_variable("beta1_power", graph: graph),
_get_non_slot_variable("beta2_power", graph: graph));
}

public override void _prepare()
{
//copied from GradientDescentOptimizer
LearningRate = _call_if_callable(LearningRate);
LearningRateTensor = ops.convert_to_tensor(LearningRate, name: "learning_rate");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public bool Run()
//int classes = y.Data<int>().Distinct().Count();
//int samples = len / classes;
int train_size = (int)Math.Round(len * (1 - test_size));
var train_x = x[new Slice(stop: train_size), new Slice()];
var valid_x = x[new Slice(start: train_size), new Slice()];
var train_y = y[new Slice(stop: train_size)];
var valid_y = y[new Slice(start: train_size)];
train_x = x[new Slice(stop: train_size), new Slice()];
valid_x = x[new Slice(start: train_size), new Slice()];
train_y = y[new Slice(stop: train_size)];
valid_y = y[new Slice(start: train_size)];
Console.WriteLine("\tDONE");
return (train_x, valid_x, train_y, valid_y);
}
Expand Down Expand Up @@ -135,7 +135,8 @@ public Graph ImportGraph()
{
// delete old cached file which contains errors
Console.WriteLine("Discarding cached file: " + meta_path);
File.Delete(meta_path);
if(File.Exists(meta_path))
File.Delete(meta_path);
}
var url = "https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/graph/" + meta_file;
Web.Download(url, "graph", meta_file);
Expand Down
9 changes: 9 additions & 0 deletions test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ public void TextClassificationTrain()
new TextClassificationTrain() { Enabled = true, DataLimit=100 }.Run();
}


[TestMethod]
public void CnnTextClassificationTrain()
{
tf.Graph().as_default();
new CnnTextClassification() { Enabled = true, IsImportingGraph = false }.Run();
}


[Ignore]
[TestMethod]
public void TextClassificationWithMovieReviews()
Expand Down