Converting Caffe layers with multiple nodes - machine-learning

I'm using caffe-tensorflow to convert a model.
I'm getting the error:
"Multiple top nodes are not supported"
I do have some layers inside the prototxt with multiple top nodes:
layer {
name: "slice2"
type: "Slice"
bottom: "conv2"
top: "slice2_1"
top: "slice2_2"
slice_param {
slice_dim: 1
}
}
Is there a way for me to do the conversion? (with or without caffe-tensorflow)
Thank you

You can't do this in caffe-tensorflow which only supports single top (output) nodes (see comments in graph.py).
Your alternatives are:
clone the github code and add the functionality
implement your model in Tensorflow code.

Related

Subtrees visualization in dtreeviz

I am new to dtreeviz.
I am struggling with a very deep decision tree that is very difficult to visualize (overfitting is not an issue for my task). I would like to know if there is a way to visualize only some nodes of the three (e.g., first 5 nodes).
Thanks!
from dtreeviz.models.xgb_decision_tree import ShadowXGBDTree
from dtreeviz import trees
xgb_shadow = ShadowXGBDTree(xgb_model_reg, 0, d.loc[:, d.columns != output_quantitativi[0]],
d[output_quantitativi[0]], d.loc[:, d.columns != output_quantitativi[0]].columns,output_quantitativi[0])
trees.dtreeviz(xgb_shadow)
for dtreeviz method it was just added the parameter depth_range_to_display, which allows you to specify a range of tree levels that you want to display.
For viz_leaf_samples() you can play with min_samples and max_samples values if the tree contains a lot of leaf nodes.

cytoscape. highlighting multiple best paths based on constraints

need help on cytoscape as I am starting up using this library but can't get answer on Cytoscape guide.
I created nodes and edges with specific weights.
I'd like to highlight for a given source and target nodes the 2 best paths. First in green and second highlighted in red.
I dont care using Dijkstra, astar, ... as long as it does the job. Both paths could follow same paths if no other choice (example if source node has only 1 connection to its neighbor). in order to filter out edge already used for first path, I create specific data (isPrimary and IsDiverse) in edge such as :
data: { id:'1', source: 'node1', target: 'node2', weight: 0, isPrimary: 0, isDiverse: 0 }. if primary path uses this edge , it will flag isPrimary to True. But cannot be able to make it work.
Do you have concrete example that would do the job as I am stuck since weeks now.
many thx for your supports.
A.
I am assuming that by best path you mean the shortest path.
The problem you describe is known as k-shortest path. Many algorithms have been developed to solve this problem. But unfortunately, as far as I know, none of them is implemented in Cytoscape.js.
Your best bet is to implement Yen's algorithm by utilizing the Dijkstra's algorithm in Cytoscape.js Here is a pseudocode (page 13).
Thx for your answer. I managed to add a parameters (data) onto each edge and flag it as True when used by the best path. Then to find the second best path that should not use the first best path, I create a condition to avoid using edges having flag sets to True.

HDF5 data layer definition for multiple HDF5 files

I know that Caffe won't let you have HDF5 data layer larger than 2GB. I had a large dataset and I split my large dataset into 5 chunks of <2GB. I listed the five files in 'train.txt' file. How can I define it in the "HDF5Data" layer in my network prototxt file? Just listing all of them as top generates an error. Any small example for this? Thanks!
Cheers
You should have text file 'train.txt' with the following content
/path/to/first.h5
/path/to/second.h5
/path/to/third.h5
/path/to/fourth.h5
/path/to/fifth.h5
Then, as source of "HDF5Data" layer you should give only 'train.txt':
layer {
type: "HDF5Data"
name: "data"
# put your "top" here, if you have several - then go ahead
hdf5_data_param {
source: "/path/to/train.txt" # only the list file goes here.
}
include { phase: TRAIN }
}
As you can see, the '/path/to/first.h5' are not listed explicitly in the train.prototxt, only in train.txt.

Openlayers 3 - Load Geometric data into Vector Layer

UPDATE: The basic question is, if my GeoJSON delivered by the REST interface (Json data is visible at end of question) is a valid GeoJSON for the vector layer, because as soon as i add this as source for the vector layer, the layer is broken.
Currently there is no REST Interface to upload shapes, so i just took some valid coordinates from current shapes and created a static JSON on serverside
I try to make it possible that users can draw shapes (Polygons, Lines) on a vector layer and the i store the geometric data on a server and the next time the map is loaded it should be displayed again. But it seems somehow when i define my REST interface as source for the vector layer, that there is some problem as painting and adding objects into the vector layer does not work anymore.
Here the code i put together from OpenLayers Examples. First an image how it should look like:
I extracted the coordinates on the map with drawend event and built a REST interface where i could load the geometric data, this is the response i get for the vector layer source:
{
"type":"FeatureCollection",
"crs":{
"type":"name",
"properties":{
"name":"EPSG:2000"
}
},
"features":[
{
"type":"Feature",
"id":"1",
"properties":{
"name":"TEST1"
},
"geometry":{
"type":"LineString",
"coordinates":[
[
-5920506.46285661,
1533632.5355137766
],
[
-1882185.384494179,
234814.55089206155
]
]
}
}
]
}
But if i load this, nothing will be displayed and its not possible to draw on the layer anymore (if i remove the "source" attribute from the vector layer source it works again)
Here the complete code on pastebin: Example Code
I fixed the problem meanwhile, i was trying to load GeoJSON into my vector layer but the vector layer was always broken afterwards. As i was pretty new to open layers, i didn't notice my mistake, but i had syntax errors in my GeoJSON and the coordinates i supplied were also wrong.
After correcting the syntax and the coordinates everything is working as intended and as mentioned above EPSG:3857 was also the right thing to use. Sorry for my first messy experiences with open layers, but thanks for the friendly help ;)

highcharts/highstock tooltips issue : point.config[2] missing, fine on subset of same data

I'm evaluating Highcharts. It is a brilliant charting solution but I've hit a problem I just cannot work out.
I have a dataset where each point has x, y, and additional data in an array for example:
[[1432022880000,6,['192.168.100.144','36215','192.168.100.191','5432','tcp']],
[[1432022880002,4,['192.168.100.144','36216','192.168.100.191','5432','tcp']],
...
I use a custom tooltip formatter to show the conversation details, which relies the metadata in the array at point.config[2]
With a fairly modest dataset size of about 300 points the tooltips won't function and I get the following in the console:
TypeError: 'undefined' is not an object (evaluating 'this.point.config[2][0]')
However, it works fine with a subset of the exact same data. Unless I've missed something there's nothing wrong the larger dataset but I'm completely stuck for what is happening. In the code of the app I use setData to update the larger series and although there are no errors thrown onto the console the point config objects lack the array at [2], and it works fine for the smaller dataset.
Here's a fiddle for the smaller(subset) of data, where the tooltip works:
http://jsfiddle.net/stevehicks/m37sdef5/14/
...and here's one for the "full" dataset where the problem exists:
http://jsfiddle.net/stevehicks/vhx66vgb/11/
Any help would be greatly appreciated as I've burnt over a day on this :(
Similar kind of issue has been reported in the High Charts Repos page
Bad Performance with large Series (tooltip specifically)
Follow up the issue and track the workaround provided on the page.
Kacper from the Highcharts support team has pointed out that it's the effect of datagrouping :
The problem is that large data set is grouped to fit in window and that grouped points do not have custom properties.
Grouping can be disabled.
plotOptions: {
series: {
turboThreshold: 0,
dataGrouping: {
enabled: false
}
}
},
Example with current version of Highstock : http://jsfiddle.net/vhx66vgb/12/
For older version this fix doesn't apply - no plot is being rendered: http://jsfiddle.net/vhx66vgb/13/
Many thanks to Kacper !!

Resources