Code Monkey home page Code Monkey logo

Comments (4)

slin07 avatar slin07 commented on August 16, 2024

This issue is essentially the question "how do we interpret shapes". In this permute case, Keras wants to permute a shape from (10,64,3) to (3,64,10); but because Keras uses (height, width, channels) for image feature axis while CoreML uses (channels, height, width), there are two ways to interpret what Permute in Keras is really doing:
(1) It wants the output tensor to be an image feature map with height=3, width=64, channels=10. In this case, the converter should respect the meaning of the axes, so the output shape should be (10,3,64).
(2) It wants the output tensor to be exactly of shape (3,64,10) with no meaning on the axes. In this case, the converter should respect the data layout in memory, so the output shape should be (3,64,10), same as Keras.
At this point the converter chooses to use (1) where the meaning of axes are respected, simply because if a Keras model has convolutions following Permute or Reshape, the converted CoreML model has the correct (C,H,W) axes to do the convolution.

from coremltools.

vellamike avatar vellamike commented on August 16, 2024

Is there a workaround for this problem? I believe it is causing issues with Conv1D layers. See https://stackoverflow.com/questions/47557591/incorrect-input-shape-in-coreml-after-converting-keras-model and https://stackoverflow.com/questions/49047418/keras-conv1d-to-coreml-not-behaving-as-expected

from coremltools.

iChiaGuo avatar iChiaGuo commented on August 16, 2024

me too

from coremltools.

TobyRoseman avatar TobyRoseman commented on August 16, 2024

Multi-backend Keras support has been removed in coremltools 6.0.

from coremltools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.