Skip to content

Remove auto-cache mechanism #1780

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

Merged
merged 16 commits into from
Dec 6, 2018
Merged

Remove auto-cache mechanism #1780

merged 16 commits into from
Dec 6, 2018

Conversation

wschin
Copy link
Member

@wschin wschin commented Nov 29, 2018

Fixes #1604.

@wschin wschin self-assigned this Nov 29, 2018
@wschin wschin requested review from TomFinley and sfilipi November 29, 2018 18:07
Copy link
Member

@sfilipi sfilipi left a comment

Choose a reason for hiding this comment

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

:shipit:

@@ -132,21 +132,16 @@ protected virtual void CheckLabelCompatible(SchemaShape.Column labelCol)
protected TTransformer TrainTransformer(IDataView trainSet,
IDataView validationSet = null, IPredictor initPredictor = null)
{
var cachedTrain = Info.WantCaching ? new CacheDataView(Host, trainSet, prefetch: null) : trainSet;
Copy link
Contributor

Choose a reason for hiding this comment

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

As requested by @GalOshri in the issue, can we add documentation?

Currently the user will have no method of knowing if a specific learner already does it own form of caching, or won't benefit from caching.

Inline w/ @GalOshri's request, I think this documentation should be required before making this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change the appropriate cookbook samples to illustrate the new pattern with this little caching checkpoint thing.


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

Copy link
Contributor

@justinormont justinormont Nov 30, 2018

Choose a reason for hiding this comment

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

Yes, updating the example code is a good first step. And we should create a direct list of the components which benefit from caching. This is along with when they benefit, for instance, "a LinearSVM when the number of iterations are greater than 1".

Another route is perhaps a VS checker which look at Info.WantCaching and recommends from there? #WontFix

Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

A sample and some tests are modified to use those caching functions. Every caching function has at least one test now. #Resolved

Copy link
Member Author

@wschin wschin Dec 5, 2018

Choose a reason for hiding this comment

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

I don't think having a list is a small task. We need another PR and issue.


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

Copy link
Member Author

@wschin wschin Dec 5, 2018

Choose a reason for hiding this comment

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

Ok. I will do it in next iteration.

[Update] Done. Please take a look again. Thank you.


In reply to: 237951764 [](ancestors = 237951764,237951473)

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, I like to see documentation in the PR. This is more so true when the user can be surprised by the change and not understand what's different.

Copy link
Member Author

Choose a reason for hiding this comment

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

Many uses are added into Coookbook.


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

.Append(ML.Transforms.Normalize("Features"));
var data = pipeline.Fit(srcDV).Transform(srcDV);
var model = ML.Regression.Trainers.OnlineGradientDescent().Fit(data);
Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

Because caching changes the behavior of batch size, we replace OnlineGradientDescent with another linear regressor. This should not affect the goal of this test. #Resolved

expectedValues.Add(new float[4] { 0.297142357F, 1, 0.2855884F, 0.193529665F });
expectedValues.Add(new float[4] { 0.45465675F, 0.8805887F, 0.4031663F, 1 });
expectedValues.Add(new float[4] { 0.0595234372F, 0.99999994F, 0.349647522F, 0.137912869F });
expectedValues.Add(new float[4] { 0.06319684F, 1, 0.1386623F, 4.46209469E-06F });
Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

This new baseline was produced using master branch. #Resolved


// Pipeline
var pipeline = new Ova(mlContext, new LinearSvm(mlContext), useProbabilities: false);
var pipeline = new Ova(mlContext, new LinearSvm(mlContext, numIterations: 100), useProbabilities: false);
Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

Since the shuffled sequence changed, it now takes more iterations to converge to previous solution. #Resolved

@@ -16,7 +16,7 @@ public void SdcaWorkout()
var dataPath = GetDataPath("breast-cancer.txt");

var data = TextLoader.CreateReader(Env, ctx => (Label: ctx.LoadFloat(0), Features: ctx.LoadFloat(1, 10)))
.Read(dataPath);
.Read(dataPath).Cache();
Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

Need to cache otherwise SDCA can't shuffle. #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

What would be user experience if you don't shuffle? Exception?


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

Copy link
Member Author

@wschin wschin Dec 5, 2018

Choose a reason for hiding this comment

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

It can be 100x slower in the worst case plus exception.


In reply to: 238883768 [](ancestors = 238883768,238761329)

var cachedValid = Info.WantCaching ? new CacheDataView(Host, validationSet, prefetch: null) : validationSet;
validRoles = MakeRoles(cachedValid);
}
validRoleMapped = MakeRoles(validationSet);
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Dec 4, 2018

Choose a reason for hiding this comment

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

just set it null as default and change only if validation set is != null #Resolved

@@ -562,6 +562,9 @@ private void CrossValidationOn(string dataPath)
Label: r.Label.ToKey(),
// Concatenate all the features together into one column 'Features'.
Features: r.SepalLength.ConcatWith(r.SepalWidth, r.PetalLength, r.PetalWidth)))
// Add a step for caching data in memory so that the downstream iterative training
// algorithm can efficiently scan through the data multiple times.
.AppendCacheCheckpoint()
Copy link
Contributor

Choose a reason for hiding this comment

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

AppendCacheCheckpoint [](start = 17, length = 21)

you need to update https://github.com/dotnet/machinelearning/blob/master/docs/code/MlNetCookBook.md with these changes. (here and in SamplesDynamicApi)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Could you take a look again?


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

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

Thank you @wschin !!

@TomFinley TomFinley merged commit 435a63b into dotnet:master Dec 6, 2018
@wschin wschin deleted the not-auto-cache branch December 6, 2018 17:50
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 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.

5 participants