BooleanIndexing.replaceWhere Not Working Based On Type - nd4j

I started working with ND4j recently and came upon an issue I don't have an explanation for.
INDArray test =
Nd4j.create(new double[] {1.0, 1.0, 2.0, 1.0}, new long[] {2, 2}, DataType.UINT16);
BooleanIndexing.replaceWhere(test, 0.0, Conditions.greaterThan(0)); // test not updated
INDArray testCasted = test.castTo(DataType.FLOAT);
BooleanIndexing.replaceWhere(testCasted, 0.0, Conditions.greaterThan(0)); // testCasted is updated
In the code above, an array created with UINT16 datatype doesn't get updated by the replaceWhere function. But when the array is casted to a FLOAT, replaceWhere works as expected. Why is this?

For now just use cast. Please feel free to file an issue and we'll take a look at that at: https://github.com/eclipse/deeplearning4j/issues - it's likely just us forgetting to auto update some of the types. Thanks!

Related

Two arrays inside an array with mongodb/mongoose

I have the following mongodb's query:
db.history.distinct('city',{code: 'A-200-01'})
Then I get this:
[1.0, 2.0]
As you can see it's a simple array.
And i'd like to get an array with two arrays inside of it using a mongoose or mongodb's query. Something like this:
"property": [ [1.0], [2.0] ]
This is my first time using mongoose and mongodb's queries so i hope you guys could help me, that would be awesome
No need to use mongodb or mongoose for that (it is probably impossible). If you need to modify output to different format the node.js itself is most usable tool.
const original = [1.0, 2.0]
const arr = [];
original.forEach(item => arr.push([item]));
console.log({property: arr});

FMI functions call order(FMI 2.0)

Which call order is correct ?
1.
fmi2SetReal/Integer/Boolean/String
fmi2SetupExperiment
fmi2EnterInitializationMode
or
2.
fmi2SetupExperiment
fmi2SetReal/Integer/Boolean/String
fmi2EnterInitializationMode
As per the standard:
"Before calling fmi2EnterInitializationMode function, all variables with
attribute can be set with the
“fmi2SetXXX” functions.fmi2SetupExperiment must be called at least once before calling
fmi2EnterInitializationMode, in order that startTime is defined."
But the order is not specified.
Pseudo code in FMI standard has fmi2SetXXX followed by fmi2SetupExperiment
//communication step size
h = 0.01;
// set all variable start values (of "ScalarVariable / / start")
s1_fmi2SetReal/Integer/Boolean/String(s1, ...);
s2_fmi2SetReal/Integer/Boolean/String(s2, ...);
//Initialize slaves
s1_fmi2SetupExperiment(s1, fmi2False, 0.0, startTime, fmi2True, stopTime);
s2_fmi2SetupExperiment(s1, fmi2False, 0.0, startTime, fmi2True, stopTime);
s1_fmi2EnterInitializationMode(s1);
Which call order is correct and why ?
Thanks in advance.
In section 3.2.3 State Machine of Calling Sequence of the FMI Standard version 2.0.1 it's stated that you are allowed to call fmi2SetSEA and fmi2SetupExperiment, where SEA is one of Real, Integer, Boolean, String for a variable with variability not equal "constant", that has initial="exact" or "approx", while in state instantiated.
So the order does not matter and both ways must be supported by every implementation of the FMI 2.0 supporting tool.
And since fmi2SetupExperiment and fmiSetSEA don't change the same data it shouldn't matter any way, as long fmi2EnterInitializationMode wasn't called.

Node's world position is always are origin - ARKit anchor

I am just trying to find world position and rotation of nodes after I detect and add planes to my AR scene.
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if !(anchor is ARPlaneAnchor) {
return
}
let plane = //to visualise planes
node.addChildNode(plane)
print("Node : \(node.worldPosition)"
}
but node.worldPosition always returns a SCNVector3(x: 0.0, y: 0.0, z: 0.0). Looks like the local position. Only the anchor gives its respective world position. I want to be able to transform the node according to the world transformations.
Thanks in advance.
tldr: Print node.worldPosition inside renderer(_:didUpdate:for:)
You are using renderer(_:didAdd:for:). Think of this as where you initially respond to a fresh new node on a new anchor. The new node hasn't yet been updated with relevant information. Adding a child plane to this new node as you did would be a good response.
In contrast, renderer(_:didUpdate:for:) is used to respond to actual updates on the node. This is when we get to see the previously added node behave as we expect. That's why you are seeing unexpected values.

If() Logic not working after xamarin update

Iam working with xamarin and monotouch and monodroid.
I have a strange problem - I just updated to the newest update in visual studio 2013 and monodroid.
In of of my classes I have the following code:
if (string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Username))
{
return;
}
Password and Username are property strings and no matter what it always
evaluate true. If both have values it still says true. Its very frustrating as
none of my code is working after the update.
Does anybody have a suggestion what to do
EDIT:
After some more digging I believe the debugger was playing a trick on me. It seemed that it hit the return when stepping - but actually it executed the subsequent code correct. However I needed to change the code. It was some simple date calculation.
var seventies = new DateTime (1970, 1, 1);
var time = DateTime.UtcNow - seventies.ToUniversalTime ();
However this triggered an out of range exception which stopped my appflow. I changed it to
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var d = DateTime.UtcNow.Subtract (epoch);
And now it seems to work. I don't like the fact that the debugger led me to believe something else was wrong. I don't like either that the datetime calculation which worked for the past year suddenly stops working.

Direct3D 10, failed on creating input layout

My application keeps failing to compile when I try to create a Vertex Layout in direct3D 10. Heres the code:
// Create the vertex input layout.
D3D10_INPUT_ELEMENT_DESC vertexDesc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0}
};
// Create the input layout
D3D10_PASS_DESC PassDesc;
mTech->GetPassByIndex(0)->GetDesc(&PassDesc);
HR(md3dDevice->CreateInputLayout(vertexDesc, 2, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &mVertexLayout));
It fails in CreateInputLayout(), I was also under the impression that HR() is meant to catch problems such as these and make suggestions in these cases, however it doesn't appear to do that. Although as with many cases I may be completely wrong on that. The prompt that comes up is :
Unhandled exception at 0x757fd36f in CourseworkApp.exe: 0x0000087A: 0x87a.
I think this is mainly related to errors with pointers but I am unsure. Any help would be much appreciated.
You should make your color format "DXGI_FORMAT_R8G8B8A8_UNORM" and change "HR(md3dDevice->CreateInputLayout..." to "if(FAILED(md3dDevice->CreateInputLayout...)) {//Handle errors}".
I think that might help fix the problem.

Resources