Comments (7)
What do you mean by NOT OK?
from coremlhelpers.
@hollance all floats from variable "c" in wrong order. Only first float is OK.
c[0,0] - OK
c[0,1] - wrong float (pointer - 0x4 + 1x1 = 1), but this float in position 459.
c[0,2] - should be in position 459 x 2 = 918.
I tried to change strides of "c" to [1, 459] and first row in output is OK, but other are wrong.
from coremlhelpers.
Can you share an example that reproduces this?
from coremlhelpers.
@hollance thank you for your CoreMLHelpers! Yes, i can.
let bbox_deltas = MultiArray<Double>(prediction.rpn_bbox_pred)
// bbox_deltas: 1x1x48x17x27
let bbox_deltas_tr = bbox_deltas
.transposed([0, 1 , 3, 4, 2])
// bbox_deltas_tr: 1x1x17x27x48
let bbox_deltas_reshaped = bbox_deltas_tr
.reshaped([5508, 4])
bbox_deltas output (from [0,0,0,0,0] to [0,0,0,0,9]):
-0.3277042210 -0.1190757155 +0.2304603755 +0.2117528319 +0.0469222963 +0.1395139992 +0.2265842110 +0.2274794430 +0.2227494419 +0.2037462592
bbox_deltas_tr output (from [0,0,0,0,0] to [0,0,0,0,9]):
-0.3277042210 -0.0869039297 +0.9364890456 -0.1947032362 -1.0869287252 -0.3563345075 +1.3238990307 -1.4743229151 -0.2934076190 -0.2424605638
bbox_deltas_reshaped output (from [0,0] to [3,3]):
-0.3277042210 -0.1190757155 +0.2304603755 +0.2117528319
+0.0469222963 +0.1395139992 +0.2265842110 +0.2274794430
+0.2227494419 +0.2037462592 +0.1262510419 +0.0418393202
-0.0091561433 +0.1211979464 +0.1764091402 +0.1841013283
bbox_deltas_reshaped NEED output (from [0,0] to [3,3]): (numbers from another platform, so -0.3280062079 is equal with my -0.3277042210)
-0.3280062079 -0.0861499831 +0.9359490871 -0.1947806776
-1.0853735209 -0.3559190333 +1.3249928951 -1.4733866453
-0.2930260003 -0.2428345680 +1.4895144701 -1.6780786514
-1.0336806774 -0.1753887385 +1.7062969208 -2.4873535633
from coremlhelpers.
I verified that this goes wrong indeed. I'll look into it shortly.
from coremlhelpers.
OK, here's what happens. The strides for array c
should be [4, 1]
so that's correct -- but that is relative to b
's view of the memory. However, what currently happens is that when c
looks up memory it does this in a
's view of the memory while it should interpret the memory as if it comes from b
.
So instead, MultiArray
should be a little smarter and tell c
how it should convert to b
's indices and then to a
's indices. So in addition to keeping track of the strides, it needs to know how to transform these to the strides of the original MLMultiArray.
I don't have time to do this right now, but pull requests are welcome. ;-) I've added a failing test case for this issue.
from coremlhelpers.
I've downgraded MultiArray to the status of "experimental code". :-) I've also added reshaped()
and transposed()
methods to MLMultiArray, which is a more robust solution.
from coremlhelpers.
Related Issues (20)
- use with macOS/NSImage HOT 4
- Is there any way to make the returned CVPixelbuffer backed by an IOSurface ? HOT 2
- How to know if coreML model would perform image-preprocessing step or not?
- Q about output Multiarray shape
- Carthage - no shared framework schemes HOT 2
- Is there any evaluation example code or helper modules on this repo? HOT 1
- Accessing elements from Dim 5 multi array not working
- Swift Package Manager Support? HOT 2
- [Feature] MLMultiArray -> UIImage without premultiplied alpha HOT 2
- Prediction discrepancies between Python's coremltools and Swift's CoreML API HOT 4
- Need help to adjust bbox for cropped images HOT 7
- pixelBuffer not public HOT 1
- MLMultiarray+Image.swift file gives error HOT 1
- How to use the transposed function? from (26, 64, 48, 1) to (1, 26, 64, 48) HOT 3
- CoreGraphics resizing function from iOS (UIImage) to MacOS (NSImage) HOT 6
- PixelBuffer function from iOS (UIImage) to MacOS (NSImage) HOT 3
- UI Image to kCVPixelFormatType_422YpCbCr8FullRange pixel format not working HOT 4
- Add support for transpose with dataType int and float
- Change image to multiArray in case of converted mlmodel from TFlite
- Question about backprop HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coremlhelpers.