Skip to content

Add "Reshape Transform" #765

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

Open
yaeldekel opened this issue Aug 29, 2018 · 4 comments
Open

Add "Reshape Transform" #765

yaeldekel opened this issue Aug 29, 2018 · 4 comments
Labels
enhancement New feature or request onnx Exporting ONNX models or loading ONNX models P1 Priority of the issue for triage purpose: Needs to be fixed soon.

Comments

@yaeldekel
Copy link

We need the following functionalities in order to score TensorFlow models:

  1. Change the ColumnType of the column to be a different shape – this would not do anything to the data, it would just change the type of the column, to match the input dimensions the model expects (for example, if the data contains a column of length 784, and the model expects a 28x28 input).
  2. Actually reshape the data – (C,H,W) to (H,W,C). This transform would also have to move data around in addition to changing the ColumnType.
  3. Reshape data from RGB to other ordering of the channels. This transform would move the data around, but leave the ColumnType as it was.

2 is already implemented as an option in the PixelExtractorTransform, and 3 could also be implemented as an option in that transform, but it may be useful to have them as a separate transform, for cases where the input data doesn't necessarily come from the PixelExtractorTransform.

@zeahmed
Copy link
Contributor

zeahmed commented Mar 14, 2019

Once we have this transform implemented, please revert the change in #2935

@codemzs codemzs added the P1 Priority of the issue for triage purpose: Needs to be fixed soon. label Jun 30, 2019
@JakeRadMSFT
Copy link
Contributor

Can we increase the priority of this? It'll be useful in Azure Attach scenarios for Model Builder and ML NET CLI. Model's exported from Azure are ONNX and expect the format to have the shape [3,224,224].

@JakeRadMSFT
Copy link
Contributor

JakeRadMSFT commented Oct 23, 2019

Just to follow up, we were able to work around it with a custom mapping. We also ended up getting a new model that didn't require it.

Example Custom Mapping that reshapes from [3,224,224] to [3 * 224 * 224].

[CustomMappingFactoryAttribute(nameof(ReshapeMapping))]
    public class ReshapeMapping : CustomMappingFactory<ReshapeInput, ReshapeOutput>
    {
        // This is the custom mapping. We now separate it into a method, so that we can use it both in training and in loading.
        public static void Mapping(ReshapeInput input, ReshapeOutput output) {
            output.Reshape = input.Reshape;
        }
        // This factory method will be called when loading the model to get the mapping operation.
        public override Action<ReshapeInput, ReshapeOutput> GetMapping()
        {
            return Mapping;
        }
    }
    public class ReshapeInput
    {
        [ColumnName("input.1")]
        [VectorType(3, 224, 224)]
        public VBuffer<float> Reshape;
    }
    public class ReshapeOutput
    {
        [ColumnName("input.1")]
        [VectorType(3 * 224 * 224)]
        public VBuffer<float> Reshape;
    }

@laurentpayot
Copy link

This issue is more than 6 years old, any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request onnx Exporting ONNX models or loading ONNX models P1 Priority of the issue for triage purpose: Needs to be fixed soon.
Projects
None yet
Development

No branches or pull requests

7 participants