Skip to content

MLContext.Model.Load overloads that take file path instead of stream. #3008

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

Closed
wants to merge 2 commits into from

Conversation

codemzs
Copy link
Member

@codemzs codemzs commented Mar 19, 2019

fixes #2991

@codecov
Copy link

codecov bot commented Mar 19, 2019

Codecov Report

Merging #3008 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3008      +/-   ##
==========================================
- Coverage   72.35%   72.35%   -0.01%     
==========================================
  Files         803      803              
  Lines      143295   143278      -17     
  Branches    16155    16155              
==========================================
- Hits       103678   103664      -14     
+ Misses      35191    35189       -2     
+ Partials     4426     4425       -1
Flag Coverage Δ
#Debug 72.35% <100%> (-0.01%) ⬇️
#production 68.07% <100%> (ø) ⬆️
#test 88.51% <100%> (-0.02%) ⬇️
Impacted Files Coverage Δ
...st/Microsoft.ML.Tests/Transformers/ConvertTests.cs 100% <100%> (ø) ⬆️
...crosoft.ML.TimeSeries.Tests/TimeSeriesDirectApi.cs 98.68% <100%> (-0.03%) ⬇️
...ests/TrainerEstimators/MatrixFactorizationTests.cs 96.88% <100%> (-0.04%) ⬇️
test/Microsoft.ML.Functional.Tests/ModelLoading.cs 93.26% <100%> (-0.43%) ⬇️
...s/Scenarios/Api/CookbookSamples/CookbookSamples.cs 99.49% <100%> (-0.01%) ⬇️
...soft.ML.TestFramework/DataPipe/TestDataPipeBase.cs 73.67% <100%> (-0.03%) ⬇️
.../Microsoft.ML.Data/Model/ModelOperationsCatalog.cs 97.54% <100%> (+0.26%) ⬆️
...enarios/Api/Estimators/TrainSaveModelAndPredict.cs 95.23% <100%> (-0.22%) ⬇️
...crosoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs 98.08% <100%> (-0.01%) ⬇️
...s/Api/CookbookSamples/CookbookSamplesDynamicApi.cs 93.49% <100%> (-0.05%) ⬇️
... and 2 more

@codemzs codemzs requested a review from eerhardt March 19, 2019 18:19
@codemzs codemzs force-pushed the modeloadfilepath1 branch from acbf668 to b2a958c Compare March 19, 2019 18:26
/// </summary>
/// <param name="stream">A readable, seekable stream to load from.</param>
/// <returns>A model of type <see cref="CompositeDataLoader{IMultiStreamSource, ITransformer}"/> containing the loader
/// and the transformer chain.</returns>
public IDataLoader<IMultiStreamSource> Load(Stream stream)
public IDataLoader<IMultiStreamSource> LoadDataLoader(Stream stream)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a similar change for the Save method?

        /// <summary>
        /// Save the model to the file.
        /// </summary>
        /// <param name="model">The trained model to be saved.</param>
        /// <param name="filePath">Path where model should be saved.</param>
        public void Save<TSource>(IDataLoader<TSource> model, string filePath)
        {
            using (var stream = File.Create(filePath))
                Save(model, stream);
        }

These are no longer symmetric.

Copy link
Member Author

@codemzs codemzs Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but this is Load API PR. I have created another PR to rename this for Save API #3019

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt @TomFinley feels we shouldn't change for Save because in .Net we have ReadChar, ReadInt, ReadDouble, etc but Write() is just one loaded set of methods. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont quite follow is there more discussion on github?


In reply to: 267100385 [](ancestors = 267100385)

/// </summary>
/// <param name="modelPath">Path to model.</param>
/// <param name="inputSchema">Will contain the input schema for the model. If the model was saved using older APIs
/// it may not contain an input schema, in this case <paramref name="inputSchema"/> will be null.</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth calling out the behavior for older models having a null input schema? That should never be the case now right?

@TomFinley
Copy link
Contributor

Similar question to that posed in #3019. Seems to be obviated by a chance in direction with these APIs now checked in, shall we close @codemzs?

@codemzs codemzs closed this Mar 26, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants