Giter Site home page Giter Site logo

Comments (7)

hollance avatar hollance commented on August 12, 2024 1

Can you add a Concat layer to the model? If not, it’s a matter of allocating a large enough memory buffer and copying things by hand. The MultiArray class is really an experimental thing, I wouldn’t use it for serious work.

from coremlhelpers.

jbmaxwell avatar jbmaxwell commented on August 12, 2024

Yikes! Is it relatively recently that you've started referring to MultiArray as "experimental"? I've been using it for a while without issue (as long as I avoid [MultiArray] structures—really not sure why that causes problems(??)), so I suppose I'm not too concerned, but it is integrated in my code fairly deeply now. Would you recommend that I remove/replace it?

As far as the concat goes, I could look into the possibility of a concat in my model. For now I've done it by hand, and it seems fine.

from coremlhelpers.

hollance avatar hollance commented on August 12, 2024

Using MultiArray is mostly fine, but there is a known issue with creating a MultiArray derived from another one. In that case it gives the wrong answers. There is a failing test case in the repo in case you're wondering exactly what I'm talking about.

from coremlhelpers.

jbmaxwell avatar jbmaxwell commented on August 12, 2024

Ah, okay. Great. Yes, as long as I avoid that I haven't had any trouble. They're handy and helpful (as "helpers", I guess they should be!)

from coremlhelpers.

jbmaxwell avatar jbmaxwell commented on August 12, 2024

Quick question: Is there a simple way to get a 3D slice from a 4D MultiArray? I have a MultiArray [4, 3, 64, 64]—i.e., just 4 x [3, 64, 64] images concatenated together—and I want to get the nth [3, 64, 64] sub matrix out.

from coremlhelpers.

hollance avatar hollance commented on August 12, 2024

Grab the pointer to the start of the MLMultiArray and increment it by n*3*64*64 and then copy the next 36464 elements. It’s just a memcpy, basically.

If you want to use MultiArray (without the ML) then you shouldn’t use the pointer but use a for loop and the subscript (because otherwise any reshaping or transposing is ignored). So now you need to loop through the array to copy out the items, which is slower than a single memcpy.

from coremlhelpers.

jbmaxwell avatar jbmaxwell commented on August 12, 2024

Thanks, I did wind up iterating over the multiArray.array, but I'll check out the memcpy version. (It's been a long time since I've used memcpy!)

from coremlhelpers.

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.