-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
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.
@@ -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; |
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.
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.
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.
Let's change the appropriate cookbook samples to illustrate the new pattern with this little caching checkpoint thing.
In reply to: 237951473 [](ancestors = 237951473)
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.
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
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.
A sample and some tests are modified to use those caching functions. Every caching function has at least one test now. #Resolved
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 don't think having a list is a small task. We need another PR and issue.
In reply to: 237953879 [](ancestors = 237953879)
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.
Ok. I will do it in next iteration.
[Update] Done. Please take a look again. Thank you.
In reply to: 237951764 [](ancestors = 237951764,237951473)
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.
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.
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.
.Append(ML.Transforms.Normalize("Features")); | ||
var data = pipeline.Fit(srcDV).Transform(srcDV); | ||
var model = ML.Regression.Trainers.OnlineGradientDescent().Fit(data); |
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.
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 }); |
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 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); |
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.
Since the shuffled sequence changed, it now takes more iterations to converge to previous solution. #Resolved
Co-Authored-By: wschin <[email protected]>
@@ -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(); |
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.
Need to cache otherwise SDCA can't shuffle. #Resolved
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.
What would be user experience if you don't shuffle? Exception?
In reply to: 238761329 [](ancestors = 238761329)
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.
It can be 100x slower in the worst case plus exception.
In reply to: 238883768 [](ancestors = 238883768,238761329)
…ding time becomes much shorter.
var cachedValid = Info.WantCaching ? new CacheDataView(Host, validationSet, prefetch: null) : validationSet; | ||
validRoles = MakeRoles(cachedValid); | ||
} | ||
validRoleMapped = MakeRoles(validationSet); |
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.
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() |
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.
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)
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.
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.
Thank you @wschin !!
Fixes #1604.