Activation output doesn't change much by input change [Synaptic] - javascript

I am using the Synaptic JS library to perform machine learning. My experience is limited to a few days now so pls forgive my ignorance on the topic. Thank you.
I am using the Architect Network with 3 inputs, 6 hidden, 6 hidden, and 1 output.
My input data is normalised and has variance.
I am using a loop to go through my dataset and to calculate for each point in time the network output. The activation output shows however low<>zero variance between each time unit while the input variance is normal. See the input and output below:
[ [ 0.363820590302, 0.3330488358480717, 0.3116651885975185 ], [
0.5172988208539779 ] ] [ [ 0.48585295937399997, 0.3334973502634277, 0.46007835102578876 ], [ 0.5172953785026767 ] ] [ [ 0.517562951083, 0.33397529189524716, 0.498643366077466 ], [
0.5172944759870963 ] ] [ [ 0.498637746879, 0.3344243285138506, 0.47562693669139866 ], [ 0.517294997539339 ] ] [ [ 0.526600573119, 0.33492075191037307, 0.5096347290849914 ], [ 0.5172941999844842 ] ] [ [ 0.531292644737, 0.3354644096344466, 0.5153411264323275 ], [
0.5172940554705523 ] ]
Where the first three are the inputs and the bold ones the corresponding output.
Am I doing something wrong?

The activation function computes f(Theta*x + b). Now the most likely case is that Theta is somehow 0 or close to 0 and that's why you only see the bias.
You should print out the initial weights of the network.

Related

Sort internal array timestamps

I have an array with multiple elements that looks like this:
{
"name": "DR",
"data": [
[
"1508112000000",
4
],
[
"1534204800000",
1
]
],
"type": "areaspline"
},
{
"name": "SIT",
"data": [
[
"1508112000000",
4
],
[
"1534204800000",
1
],
[
"1506384000000",
3
],
[
"1534204800000",
1
],
[
"1531094400000",
1
],
[
"1528502400000",
1
]
],
"type": "areaspline"
},
This is the exact format I use to send data into high charts, however, the problem is that the chart breaks if the timestamps inside each environment (DR, SIT) are not in order.
How can I sort the 'data' inside each environment by timestamp?
This JSON is generated in PHP and sent through to JavaScript. So I would like to know how to sort the data inside either PHP or JavaScript.
Thanks.
This is actually rather trivial, once you know about the usort function. It allows you to define your own sorting function, so you can sort based on any factor of whatever the 2 objects it is passed.
Note that from your example json I had to add a set of square brackets around the whole thing to get PHP to parse it with json_decode .
<?php
// note I had to add square brackets to your
// demo json ....
$json='[{
"name": "DR",
"data": [
[
"1508112000000",
4
],
[
"1534204800000",
1
]
],
"type": "areaspline"
},
{
"name": "SIT",
"data": [
[
"1508112000000",
4
],
[
"1534204800000",
1
],
[
"1506384000000",
3
],
[
"1534204800000",
1
],
[
"1531094400000",
1
],
[
"1528502400000",
1
]
],
"type": "areaspline"
}]';
$json_obj_arr=json_decode($json,true);
print_r($json_obj_arr);
print("\n\n");
// a function to handle the sorting itself
// usort will pass it an array(timestamp,datavalue) for both
// $a and $b so we compare the [0] element of each
function cmp($a, $b)
{
if ($a[0] == $b[0]) {
return 0;
}
return ($a[0] < $b[0]) ? -1 : 1;
}
// loop through the array, first is indexed
for($i=0;$i<count($json_obj_arr);$i++){
// then each one of those contains an
// associtive array with an element named ['data'] -
// this is an indexed array that you want sorted
// on the [0] element
usort($json_obj_arr[$i]['data'],"cmp");
}
print_r($json_obj_arr);
print("\n\n");
?>

How can I have multiple links on the same level as the main page in doxygen without breaking the link highlighting

I am trying to make it where my links in doxygen on my tree-style navbar have multiple links on the same level as the main page. I was able to accomplish that by changing the order of links in the navtreedata.js . Now the problem is that by doing this I appear to have made it where it thinks everything on the first level of links is the index/mainpage as far as the navtree is concerned. It shows the index/mainpage with the blue highlight behind it as if it is the one I clicked. The page displays the right information but it looks weird. Even worse, I have some links I placed on the top level of links(same level as the main page)that have subpages. Whenever I click a subpage it folds up the foldout, which is really annoying. Anyone know how I can fix this? I am afraid I will need to modify the navtree.js or the html/css somewhere but I don't know much about javascript or HTML/CSS. I believe it is upset because my links no longer match up with the indexes they are given in the navtreeindex0.js.Also if anyone knows an easier way of accomplishing my goals without changing the navtreedata.js please let me know.
The javacript for my navetree since I was asked for code:
var NAVTREE =
[
[ "Main page", "index.html", [
[ "page 1", "page1.html", null ],
[ "page2", "page2.html", [
[ page3", "page3.html", null ],
[ "page4", "page4.html", null],
[ "page5", "page5.html", [
[ "page6", "page6.html", null ],
[ "page7", "page7.html", null ]
] ],
[ "page8", "page8.html", null ]
] ],
[ "page9", null, [
[ "page10", "page10.html", null ]
] ],
[ "page11", "page11.html", null ]
] ],
[ "SECOND LEVEL MENU ENTRY", "sample-file-secondary.html", [
[ "page 12", "page12.html", null ],
[ "page 13", "page13.html", null ]
] ],
[ "THIRD LEVEL MENU ENTRY", "sample-file-third.html"]
];
var NAVTREEINDEX =
[
".html"
];
var SYNCONMSG = 'click to disable panel synchronisation';
var SYNCOFFMSG = 'click to enable panel synchronisation';

Syphoning out irregularities in a large array using a loop. JS

I have this huge array that is representing opening and closing times. (this stretches for an entire week). I also created a new feature in which it allows users to have holiday hours in which they can change their hours....but also close their doors during a specific day. The problem that I've run across is when a customer chooses to close for a day, the date for the large array becomes a blank array.
Is there an effective way to trigger something if the elements inside one of those arrays return nothing?
[
[],
[
"2015-10-16T13:00:00Z",
"2015-10-16T21:00:00Z"
],
[],
[
"2015-10-18T13:00:00Z",
"2015-10-18T21:00:00Z"
],
[
"2015-10-19T05:00:00Z",
"2015-10-20T05:00:00Z"
],
[
"2015-10-20T13:00:00Z",
"2015-10-20T21:00:00Z"
],
[
"2015-10-21T13:00:00Z",
"2015-10-21T21:00:00Z"
]
]
So up here ^^ is what my large array looks like when a customer chooses to be closed for the day.
You can use .map and check for x.length === 0 condition.
(function() {
var data = [
[],
[
"2015-10-16T13:00:00Z",
"2015-10-16T21:00:00Z"
],
[],
[
"2015-10-18T13:00:00Z",
"2015-10-18T21:00:00Z"
],
[
"2015-10-19T05:00:00Z",
"2015-10-20T05:00:00Z"
],
[
"2015-10-20T13:00:00Z",
"2015-10-20T21:00:00Z"
],
[
"2015-10-21T13:00:00Z",
"2015-10-21T21:00:00Z"
]
];
data.map(function(x, y) {
if (x.length === 0) {
console.log("There is no data in the position: " + y + ".");
}
});
})();

Access anonymous array using NgRepeat

I have a multi-level array containing some objects at its deepest level.
[
[
[
"FUND",
{
"totassets":10.9,
"totdate":"2015-03-23",
"expratiogross":1.35,
"exprationet":1.08
}
],
[
"DAILY",
{
"navdate":"2015-03-23",
"nav":10.05,
"chgamt":0,
"chgpct":0,
"pop":10.05,
"ytdreturn":2.03,
"curr7dayyield":0,
"eff7dayyield":0,
"unsub7dayyield":0,
"30dayyield":0,
"30dayloadyield":0
}
]
]
]
I would like to use ngRepeat to display all the items in "FUND" or "DAILY" but I'm unsure how to access objects this deep without names for each of the arrays above.
Sorry if this is a basic question but I wasn't able to find an answer elsewhere.
You'll want to get the first element of your two outer arrays.
$scope.obj = [
[
[
"FUND",
{
"totassets":10.9,
"totdate":"2015-03-23",
"expratiogross":1.35,
"exprationet":1.08
}
],
[
"DAILY",
{
"navdate":"2015-03-23",
"nav":10.05,
"chgamt":0,
"chgpct":0,
"pop":10.05,
"ytdreturn":2.03,
"curr7dayyield":0,
"eff7dayyield":0,
"unsub7dayyield":0,
"30dayyield":0,
"30dayloadyield":0
}
]
]
]
<ng-repeat el in obj[0][0]>
<span>totassets: {{el[0].FUND.totalAssets}}</span>
<span>navdate: {{el[0].DAILY.navdate}}</span>
</ng-repeat>
An issue you have with the array is that even when you ignore the outer arrays, you're still left with two individual arrays a la:
[
"FUND",
{
"totassets":10.9,
"totdate":"2015-03-23",
"expratiogross":1.35,
"exprationet":1.08
}
],
And:
[
"DAILY",
{
"navdate":"2015-03-23",
"nav":10.05,
"chgamt":0,
"chgpct":0,
"pop":10.05,
"ytdreturn":2.03,
"curr7dayyield":0,
"eff7dayyield":0,
"unsub7dayyield":0,
"30dayyield":0,
"30dayloadyield":0
}
]
So you will need two ngRepeat blocks to achieve what I assume you want to achieve as well as going one level deeper to actually access the values you want.
Here's a quick plnkr to demonstrate what I mean: http://plnkr.co/edit/ArCh8q8w2JoXsg107XwP?p=preview

Masonry.js And Floated Div Issues

I'm using masonry.js quite a lot in a new website that I'm developing but there is one flaw with using it in my design when it comes to floating my columns side by side. Here is a general representation of what I'm trying to do:
Normal View:
[ column left ] [ main column ] [[masonry post]] [ column right ]
[ ] [ ] [[masonry post]] [ ]
[ ] [ ] [[masonry post]] [ ]
[ ] [ ] [[masonry post]] [ ]
[ ] [ ] [[masonry post]] [ ]
Responsive view:
[ column left ] [ main column ] [ column right ]
[ ] [ ] [ ]
[ ] [ ] [ ]
[ ] [ [masonry post][masonry post] ] [ ]
[ ] [ [masonry post][masonry post] ] [ ]
[ ] [ [masonry post][masonry post] ] [ ]
So the "main column" and "masonry post" columns are floated left so that when the browser is shrunk down, the masonry column goes beneath the main column, which in theory works perfectly, however because Masonry JS is applied to the masonry column it doesn't move like it's supposed to - Instead, it stays where it is and gets hidden behind the right hand column. Any ideas on how this can be sorted?

Categories

Resources