-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Exposed TensorFLow session as TensorFlowModelInfo class #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…chema and TFTransform.
| using Microsoft.ML.Runtime; | ||
| using Microsoft.ML.Runtime.Data; | ||
|
|
||
| namespace Microsoft.ML.Transforms.TensorFlow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably put it into same namespace as tensorflow transform, i.e. Microsoft.ML.Transforms.
Also requires update in documentation.
Would be nice to explain user in which case he need to use simple constructor and in which this Context object. #Closed
| { | ||
| /// <summary> | ||
| /// This class holds the information related to TensorFLow model and session. | ||
| /// It provides a convenient way to query model schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chema [](start = 53, length = 5)
please use correct punctuation #Closed
| /// </summary> | ||
| public class TensorFlowModelContext | ||
| { | ||
| internal TFSession Session { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private set; [](start = 42, length = 12)
use just { get; } for read-only properties #Closed
| internal TFSession Session { get; private set; } | ||
| public string ModelPath { get; private set; } | ||
|
|
||
| private readonly IHostEnvironment _host; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_host [](start = 42, length = 5)
either rename to _env or register an IHost #Closed
| } | ||
|
|
||
| /// <summary> | ||
| /// Get <see cref="ISchema"/> for only those nodes which are marked "PlaceHolder" in the TensorFlow model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlaceHolder [](start = 77, length = 11)
is it PlaceHolder or Placeholder ? #Closed
| /// - Get complete schema by calling <see cref="GetModelSchema()"/> | ||
| /// - Get schema related to model input by calling <see cref="GetInputSchema()"/> | ||
| /// </summary> | ||
| public class TensorFlowModelContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TensorFlowModelContext [](start = 17, length = 22)
can we think of a better name than Context ? We are trying to limit ML.NET to just one context, called MLContext #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something along the lines of 'handle', or I don't know, Info ?
In reply to: 223784755 [](ancestors = 223784755)
| { | ||
| var imageHeight = 32; | ||
| var imageWidth = 32; | ||
| var tensorFlowContext = TensorFlowUtils.LoadTensorFlowModel(env, model_location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tensorFlowContext [](start = 20, length = 17)
tensorFlowModel maybe? Since name of the class in not Context anymore #Closed
| private sealed class Reconciler : EstimatorReconciler | ||
| { | ||
| private readonly string _modelFile; | ||
| private readonly TensorFlowModelInfo _tensorFlowModelContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tensorFlowModelContext [](start = 49, length = 23)
_tensorFlowModelInfo maybe? #Closed
Zruty0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
| public Reconciler(string modelFile) | ||
| { | ||
| Contracts.AssertNonEmpty(modelFile); | ||
| _modelFile = modelFile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_modelFile [](start = 16, length = 10)
I would probably get rid of _modelFile and just use _tensorFlowModelContext since you can create it from modelFile anyway.
Less complicated I think from code standpoint #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...I tried and think that its better to keep it as-is. The reason is because TensorFlowUtils.LoadTensorFlowModel requires IHostEnvironment which is not available until Reconcile method is hit.
Let me know if you are thinking of some other solution?
In reply to: 223836239 [](ancestors = 223836239)
| namespace Microsoft.ML.Transforms.TensorFlow | ||
| { | ||
| /// <summary> | ||
| /// This class holds the information related to TensorFLow model and session. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L [](start = 59, length = 1)
nit: typo #Resolved
Ivanidzo4ka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
This PR fixes #1157 where loaded
TFSessionis wrapped intoTensorFlowModelInfoclass.In addition to that, the
TensorFlowModelInfoprovides following methods to query schemaISchemaobject.ISchemaobject. It is useful for the case when the graph is very large and user cannot locate inputs in such a large graphs.Please see the modified test for more insights.