version: 0.11
Related: #1424
When training a softmax Multi classifier with LightGBM a save/load will lose the softmax it seems:
Also inspecting the model we can see it doesn't use ImplSoftmax but ImplRaw.
Reproduce:
publicclassGenericSample{publicstringA{get;set;}publicstringLabel{get;set;}}publicstaticvoidReproduceLightGbmPersistanceBug(){vardata=Enumerable.Range(1,100).Select(x =>newGenericSample{A=$"{x%20}",Label=$"{x%10}"});varctx=newMLContext();varoptions=newOptions{UseSoftmax=true,};varpipe=ctx.Transforms.Categorical.OneHotEncoding("A").Append(ctx.Transforms.Concatenate("Features","A")).Append(ctx.Transforms.Conversion.MapValueToKey("Label")).Append(ctx.MulticlassClassification.Trainers.LightGbm(options));vardataView=ctx.Data.LoadFromEnumerable(data);ITransformermodel=pipe.Fit(dataView);varscores=model.Transform(dataView).GetColumn<float[]>(ctx,"Score");Console.WriteLine($"Min: {scores.Select(x =>x.Min()).Min()}");Console.WriteLine($"Max: {scores.Select(x =>x.Max()).Max()}");varmemoryStream=newMemoryStream();ctx.Model.Save(model,memoryStream);model=ctx.Model.Load(memoryStream);scores=model.Transform(dataView).GetColumn<float[]>(ctx,"Score");Console.WriteLine($"Min: {scores.Select(x =>x.Min()).Min()}");Console.WriteLine($"Max: {scores.Select(x =>x.Max()).Max()}");}Output:
Min: 0.001027671
Max: 0.9907509
Min: -4.843706
Max: 2.027462
version: 0.11
Related: #1424
When training a softmax Multi classifier with LightGBM a save/load will lose the softmax it seems:
Also inspecting the model we can see it doesn't use
ImplSoftmaxbutImplRaw.Reproduce:
Output: