Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Microsoft.ML.Core/Data/IEstimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ public enum VectorKind

public readonly string Name;
public readonly VectorKind Kind;
public readonly DataKind ItemKind;
public readonly ColumnType ItemType;

@TomFinley TomFinley Aug 28, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ColumnType ItemType [](start = 28, length = 19)

This is somewhat problematic for key columns. How do we represent the two distinct concepts of a key-columns of known and unknown counts? #Pending

@Zruty0 Zruty0 Aug 28, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, ItemType is never supposed to be a key. For example, for a scalar key column, the correct representation is Kind = Scalar, ItemType = PrimitiveType.U4, IsKey = true.

I think I should enforce it in constructor even.

I don't think we should even have key types of unknown counts: it is already causing issues for Term transform, and I'm yet to see any benefit of this type.


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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that keys of unknown size should go away, but are we going to do this in this PR?

That we're representing a key-type using a column type which is not a key-type at all, and whose only connection to it is that their DataKind happen to be the same, is rather odd and unfortunate. I hope we can imagine a better way here, though I'm not sure I see one right off the bat.


In reply to: 213156549 [](ancestors = 213156549,213151407)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are also representing a vector type using a column type which is not a vector-type at all, and whose only connection to it is that their ItemType happen to be the same :)


In reply to: 214125274 [](ancestors = 214125274,213156549,213151407)

public readonly bool IsKey;
public readonly string[] MetadataKinds;

public Column(string name, VectorKind vecKind, DataKind itemKind, bool isKey, string[] metadataKinds = null)
public Column(string name, VectorKind vecKind, ColumnType itemType, bool isKey, string[] metadataKinds = null)
{
Contracts.CheckNonEmpty(name, nameof(name));
Contracts.CheckValueOrNull(metadataKinds);

Name = name;
Kind = vecKind;
ItemKind = itemKind;
ItemType = itemType;
IsKey = isKey;
MetadataKinds = metadataKinds ?? new string[0];
}
Expand All @@ -51,7 +51,7 @@ public Column(string name, VectorKind vecKind, DataKind itemKind, bool isKey, st
/// requirement.
///
/// Namely, it returns true iff:
/// - The <see cref="Name"/>, <see cref="Kind"/>, <see cref="ItemKind"/>, <see cref="IsKey"/> fields match.
/// - The <see cref="Name"/>, <see cref="Kind"/>, <see cref="ItemType"/>, <see cref="IsKey"/> fields match.
/// - The <see cref="MetadataKinds"/> of <paramref name="inputColumn"/> is a superset of our <see cref="MetadataKinds"/>.
/// </summary>
public bool IsCompatibleWith(Column inputColumn)
Expand All @@ -61,7 +61,7 @@ public bool IsCompatibleWith(Column inputColumn)
return false;
if (Kind != inputColumn.Kind)
return false;
if (ItemKind != inputColumn.ItemKind)
if (!ItemType.Equals(inputColumn.ItemType))
return false;
if (IsKey != inputColumn.IsKey)
return false;
Expand All @@ -72,7 +72,7 @@ public bool IsCompatibleWith(Column inputColumn)

public string GetTypeString()
{
string result = ItemKind.ToString();
string result = ItemType.ToString();
if (IsKey)
result = $"Key<{result}>";
if (Kind == VectorKind.Vector)
Expand Down Expand Up @@ -110,13 +110,13 @@ public static SchemaShape Create(ISchema schema)
else
vecKind = Column.VectorKind.Scalar;

var kind = type.ItemType.RawKind;
var itemKind = type.ItemType.RawKind;
var isKey = type.ItemType.IsKey;

var metadataNames = schema.GetMetadataTypes(iCol)
.Select(kvp => kvp.Key)
.ToArray();
cols.Add(new Column(schema.GetColumnName(iCol), vecKind, kind, isKey, metadataNames));
cols.Add(new Column(schema.GetColumnName(iCol), vecKind, PrimitiveType.FromKind(itemKind), isKey, metadataNames));
}
}
return new SchemaShape(cols.ToArray());
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.ImageAnalytics/EntryPoints/ImageAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class ImageAnalytics
public static CommonOutputs.TransformOutput ImageLoader(IHostEnvironment env, ImageLoaderTransform.Arguments input)
{
var h = EntryPointUtils.CheckArgsAndCreateHost(env, "ImageLoaderTransform", input);
var xf = new ImageLoaderTransform(h, input, input.Data);
var xf = ImageLoaderTransform.Create(h, input, input.Data);
return new CommonOutputs.TransformOutput()
{
Model = new TransformModel(h, xf, input.Data),
Expand All @@ -29,7 +29,7 @@ public static CommonOutputs.TransformOutput ImageLoader(IHostEnvironment env, Im
public static CommonOutputs.TransformOutput ImageResizer(IHostEnvironment env, ImageResizerTransform.Arguments input)
{
var h = EntryPointUtils.CheckArgsAndCreateHost(env, "ImageResizerTransform", input);
var xf = new ImageResizerTransform(h, input, input.Data);
var xf = ImageResizerTransform.Create(h, input, input.Data);
return new CommonOutputs.TransformOutput()
{
Model = new TransformModel(h, xf, input.Data),
Expand Down
Loading