-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added categorical value support for PredictedLabel for the Image Classification Transfer Learning example. Addresses Issue #4169 #4228
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
Changes from 2 commits
8d07401
d80e23d
7b239b0
33e71ae
2b1ab69
7254a7e
1a43cc7
d39f98b
8cf2b7c
c4182fb
d490383
01c77c9
380d8bf
2af03ca
2c05ba8
6356665
ed928c6
f7f8253
bd42f0a
f851791
643fb58
b6cfeda
cca4fb8
1c4c5dc
2301a96
26e2ae1
94c0423
109879b
6ff4c64
15c4654
0573ef3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -878,7 +878,7 @@ protected override DataViewSchema.DetachedColumn[] GetOutputColumnsCore() | |
| { | ||
| var info = new DataViewSchema.DetachedColumn[_parent._outputs.Length]; | ||
| info[0] = new DataViewSchema.DetachedColumn(_parent._outputs[0], new VectorDataViewType(NumberDataViewType.Single, _parent._classCount), null); | ||
| info[1] = new DataViewSchema.DetachedColumn(_parent._outputs[1], NumberDataViewType.UInt32, null); | ||
| info[1] = new DataViewSchema.DetachedColumn(_parent._outputs[1], new KeyDataViewType(typeof(uint), _parent._classCount), ((DataViewSchema.Column)InputSchema.GetColumnOrNull(_parent._labelColumnName)).Annotations); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We cannot rely on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please replace this field with two fields containing the score column name and the predicted label column name, and do the same for the argument in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed that there is the same problem with the input column names - on one hand the argument in the In reply to: 326619105 [](ancestors = 326619105) |
||
| return info; | ||
| } | ||
| } | ||
|
|
@@ -1166,7 +1166,7 @@ internal ImageClassificationEstimator(IHostEnvironment env, Options options, Dnn | |
| _options = options; | ||
| _dnnModel = dnnModel; | ||
| _tfInputTypes = new[] { TF_DataType.TF_STRING }; | ||
| _outputTypes = new[] { new VectorDataViewType(NumberDataViewType.Single), NumberDataViewType.UInt32.GetItemType() }; | ||
| _outputTypes = new DataViewType[] { new VectorDataViewType(NumberDataViewType.Single), new KeyDataViewType(typeof(uint), 5) }; | ||
|
mstfbl marked this conversation as resolved.
Outdated
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good catch, thank you! Quick question, the Image Classification example ResnetV2101TransferLearningTrainTestSplit.cs runs perfectly well when I don't further define _outputTypes, i,e, delete line 69. Does this also mean than the estimator isn't using this field? #Resolved
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I've found that the DataViewType field is needed for the pipeline in ResnetV2101TransferLearningTrainTestSplit.cs to fit properly. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? The only place In reply to: 326329163 [](ancestors = 326329163)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was giving a different error when I removed _outputTypes, but as I now see that was not the bottleneck problem I was having while implementing this KeyType solution. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The field In reply to: 326229209 [](ancestors = 326229209)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed this, thank you for the catch! #Resolved |
||
| } | ||
|
|
||
| private static Options CreateArguments(DnnModel tensorFlowModel, string[] outputColumnNames, string[] inputColumnName, bool addBatchDimensionInput) | ||
|
|
@@ -1196,12 +1196,16 @@ public SchemaShape GetOutputSchema(SchemaShape inputSchema) | |
| if (col.ItemType != expectedType) | ||
| throw _host.ExceptSchemaMismatch(nameof(inputSchema), "input", input, expectedType.ToString(), col.ItemType.ToString()); | ||
| } | ||
| for (var i = 0; i < _options.OutputColumns.Length; i++) | ||
| { | ||
| resultDic[_options.OutputColumns[i]] = new SchemaShape.Column(_options.OutputColumns[i], | ||
| _outputTypes[i].IsKnownSizeVector() ? SchemaShape.Column.VectorKind.Vector | ||
| : SchemaShape.Column.VectorKind.VariableVector, _outputTypes[i].GetItemType(), false); | ||
| } | ||
|
|
||
| resultDic[_options.OutputColumns[0]] = new SchemaShape.Column(_options.OutputColumns[0], | ||
| SchemaShape.Column.VectorKind.Vector, _outputTypes[0].GetItemType(), false); | ||
|
|
||
| var metadata = new List<SchemaShape.Column>(); | ||
| metadata.Add(new SchemaShape.Column(AnnotationUtils.Kinds.KeyValues, SchemaShape.Column.VectorKind.Vector, TextDataViewType.Instance, false)); | ||
|
|
||
| resultDic[_options.OutputColumns[1]] = new SchemaShape.Column(_options.OutputColumns[1], | ||
| SchemaShape.Column.VectorKind.Scalar, NumberDataViewType.UInt32, true, new SchemaShape(metadata.ToArray())); | ||
|
|
||
| return new SchemaShape(resultDic.Values); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.