diff --git a/build/Dependencies.props b/build/Dependencies.props
index a251c7dcbd..49e2d5ce87 100644
--- a/build/Dependencies.props
+++ b/build/Dependencies.props
@@ -21,7 +21,7 @@
4.5.0
4.5.0
4.5.0
- 1.10.0
+ 1.12.0
diff --git a/src/Microsoft.ML.Data/Transforms/ConversionsExtensionsCatalog.cs b/src/Microsoft.ML.Data/Transforms/ConversionsExtensionsCatalog.cs
index aeb6e23743..cdcd3a83f2 100644
--- a/src/Microsoft.ML.Data/Transforms/ConversionsExtensionsCatalog.cs
+++ b/src/Microsoft.ML.Data/Transforms/ConversionsExtensionsCatalog.cs
@@ -140,5 +140,22 @@ public static ValueMappingEstimator ValueMap values,
params (string outputColumnName, string inputColumnName)[] columns)
=> new ValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), keys, values, columns);
+
+ ///
+ /// Maps the using the keys in the dictionary to the values of dictionary i.e.
+ /// a value 'x' in the would be mappped to a value stored in dictionary[x].
+ /// In this case, the is used to build up the dictionary where
+ /// and specify the keys and values of dictionary respectively.
+ ///
+ /// The categorical transform's catalog
+ /// An instance of that contains the key and value columns.
+ /// Name of the key column in .
+ /// Name of the value column in .
+ /// The columns to apply this transform on.
+ ///
+ public static ValueMappingEstimator ValueMap(
+ this TransformsCatalog.ConversionTransforms catalog,
+ IDataView lookupMap, string keyColumn, string valueColumn, params (string outputColumnName, string inputColumnName)[] columns)
+ => new ValueMappingEstimator(CatalogUtils.GetEnvironment(catalog), lookupMap, keyColumn, valueColumn, columns);
}
}
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha
deleted file mode 100644
index da8b53866b..0000000000
--- a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.10.0.tar.gz.sha
+++ /dev/null
@@ -1 +0,0 @@
-77218EC4DA96A73B15B8AA5637C9F21B389510A9FAF4DCF06DF5B81A5403015C6BA3EEE29BD8BA5B0694F40C671D8E6722D554C4F93F95C33F29AB491C70263C
\ No newline at end of file
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.12.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.12.0.tar.gz.sha
new file mode 100644
index 0000000000..d1167ceb9b
--- /dev/null
+++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-darwin-x86_64-1.12.0.tar.gz.sha
@@ -0,0 +1 @@
+090706417EC29D91EEEABC5C25576374A86426CF25F27556C0EED4FD815D814C4F09FA7389ED8F614E4B34BF6438B9AE0ADA402BEA7CC9441446AB783A6F187D
\ No newline at end of file
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha
deleted file mode 100644
index 6b865984ec..0000000000
--- a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.10.0.tar.gz.sha
+++ /dev/null
@@ -1 +0,0 @@
-B9E9CD95BC6A28297ACAB0D684FBBFAFF1F9AE893432AC2D208120D767101AC20E2C55BC79E59DBE6E5BD9EC802026694960FA12137BB303061C5A21B62BD29E
\ No newline at end of file
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.12.0.tar.gz.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.12.0.tar.gz.sha
new file mode 100644
index 0000000000..92dc9e7d0a
--- /dev/null
+++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-linux-x86_64-1.12.0.tar.gz.sha
@@ -0,0 +1 @@
+5359609DDF69D66474F720D6A1ED669942FEB6842096CFC3EAF44B84FA3F2F659829778446BD3C7C83871F7293CA481AC4732DF6DC7921ADA100B459E37198BD
\ No newline at end of file
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha
deleted file mode 100644
index 92ce0db9fb..0000000000
--- a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.10.0.zip.sha
+++ /dev/null
@@ -1 +0,0 @@
-66F3A9522917076038AE9CCA11FE805DD516C60B3A3E156B78C2E4BD0E3E5785A9D0380C5E06411473EF14A72B72FD93F954AA3496A12D1FAF0FA3393970E700
\ No newline at end of file
diff --git a/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.12.0.zip.sha b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.12.0.zip.sha
new file mode 100644
index 0000000000..4d5e6ce4d6
--- /dev/null
+++ b/src/Redist/Microsoft.ML.TensorFlow.Redist/libtensorflow-cpu-windows-x86_64-1.12.0.zip.sha
@@ -0,0 +1 @@
+49DB72CDD8D10B78BB1CD17A058DF508E04B38BD287FF53EB9173A48D3994E11741B1EE6C9108303739819845F2F9D777EE3E767D737C24DB3A28B67FF68C951
\ No newline at end of file
diff --git a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj
index e655c73f33..2d56666b7f 100644
--- a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj
+++ b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj
@@ -46,7 +46,7 @@
-
+
diff --git a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
index 3b66f3eda1..bb46984a38 100644
--- a/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
+++ b/test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
@@ -11,8 +11,10 @@
using Microsoft.ML.ImageAnalytics;
using Microsoft.ML.RunTests;
using Microsoft.ML.Transforms;
+using Microsoft.ML.Transforms.Conversions;
using Microsoft.ML.Transforms.Normalizers;
using Microsoft.ML.Transforms.TensorFlow;
+using Microsoft.ML.Transforms.Text;
using Xunit;
namespace Microsoft.ML.Scenarios
@@ -846,5 +848,59 @@ public void TensorFlowTransformCifarInvalidShape()
}
Assert.True(thrown);
}
+
+ ///
+ /// Class to hold features and predictions.
+ ///
+ public class TensorFlowSentiment
+ {
+ public string Sentiment_Text;
+ [VectorType(600)]
+ public int[] Features;
+ [VectorType(2)]
+ public float[] Prediction;
+ }
+
+ [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))]
+ public void TensorFlowSentimentClassificationTest()
+ {
+ var mlContext = new MLContext(seed: 1, conc: 1);
+ var data = new[] { new TensorFlowSentiment() { Sentiment_Text = "this film was just brilliant casting location scenery story direction everyone's really suited the part they played and you could just imagine being there robert is an amazing actor and now the same being director father came from the same scottish island as myself so i loved the fact there was a real connection with this film the witty remarks throughout the film were great it was just brilliant so much that i bought the film as soon as it was released for and would recommend it to everyone to watch and the fly fishing was amazing really cried at the end it was so sad and you know what they say if you cry at a film it must have been good and this definitely was also to the two little boy's that played the of norman and paul they were just brilliant children are often left out of the list i think because the stars that play them all grown up are such a big profile for the whole film but these children are amazing and should be praised for what they have done don't you think the whole story was so lovely because it was true and was someone's life after all that was shared with us all" } };
+ var dataView = mlContext.Data.ReadFromEnumerable(data);
+
+ var lookupMap = mlContext.Data.ReadFromTextFile(@"sentiment_model/imdb_word_index.csv",
+ columns: new[]
+ {
+ new TextLoader.Column("Words", DataKind.TX, 0),
+ new TextLoader.Column("Ids", DataKind.I4, 1),
+ },
+ separatorChar: ','
+ );
+
+ // We cannot resize variable length vector to fixed length vector in ML.NET
+ // The trick here is to create two pipelines.
+ // The first pipeline 'dataPipe' tokenzies the string into words and maps each word to an integer which is an index in the dictionary.
+ // Then this integer vector is retrieved from the pipeline and resized to fixed length.
+ // The second pipeline 'tfEnginePipe' takes the resized integer vector and passes it to TensoFlow and gets the classification scores.
+ var estimator = mlContext.Transforms.Text.TokenizeWords("TokenizedWords", "Sentiment_Text")
+ .Append(mlContext.Transforms.Conversion.ValueMap(lookupMap, "Words", "Ids", new[] { ("Features", "TokenizedWords") }));
+ var dataPipe = estimator.Fit(dataView)
+ .CreatePredictionEngine(mlContext);
+
+ // For explanation on how was the `sentiment_model` created
+ // c.f. https://github.com/dotnet/machinelearning-testdata/blob/master/Microsoft.ML.TensorFlow.TestModels/sentiment_model/README.md
+ string modelLocation = @"sentiment_model";
+ var tfEnginePipe = mlContext.Transforms.ScoreTensorFlowModel(modelLocation, new[] { "Prediction/Softmax" }, new[] { "Features" })
+ .Append(mlContext.Transforms.CopyColumns(("Prediction", "Prediction/Softmax")))
+ .Fit(dataView)
+ .CreatePredictionEngine(mlContext);
+
+ var processedData = dataPipe.Predict(data[0]);
+ Array.Resize(ref processedData.Features, 600);
+ var prediction = tfEnginePipe.Predict(processedData);
+
+ Assert.Equal(2, prediction.Prediction.Length);
+ Assert.InRange(prediction.Prediction[1], 0.650032759 - 0.01, 0.650032759 + 0.01);
+ }
}
}