How to do Unpooling with caffe standard version - neural-network

I have seen users are using unpooling layer, which is mostly based on their own release of Caffe. For example this:
layer { type: "UnPooling" bottom: "fc6-deconv" bottom: "pool5_mask" top: "unpool5" name: "unpool5"
unpooling_param { unpool: MAX kernel_size: 2 stride: 2 unpool_size: 14 }
}
In which pool5_mask is coming from this Poooling layer:
layer {
bottom: "conv5_3" top: "pool5" top: "pool5_mask" name: "pool5" type: "Pooling"
pooling_param { pool: MAX kernel_size: 2 stride: 2 }
}
Is it possible to do UnPooling operation using Caffe standard version.? If yes, could you please show some examples? I looked into layer catalog, however, I could not find unpooling operation.
Your help is appreciated.

Related

caffe: A CNN with two loss layers and two different label sets

I am interested to have a deep CNN with two loss layers, each of them having its own separate label set. For example, imagine a 10 layer CNN, loss1 is located in 5th layer using label1, then loss2 in the last layer using label2.
Note: label1 (loss1) can be considered as pre-processing step, in order to ease the task of the CNN to solve label2 (loss2 i.e. real label).
Question: as far as i know, caffe loss layer automatically uses "label" (in my .lmdb dataset). how to make it to use "label1" in loss1 and "label2" in the loss2?
Update: so i took Shai's advice to use HDF5. here is my progress so far (giving only the input and output layers):
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label1"
top: "label2"
include {
phase: TEST
}
hdf5_data_param {
source: "data/2048_1e3_0.00/2048_1e3_0.00_s_val_list.txt"
}
}
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label1"
top: "label2"
include {
phase: TRAIN
}
hdf5_data_param {
source: "data/2048_1e3_0.00/2048_1e3_0.00_s_train_list.txt"
}
...
layer {
name: "loss1"
type: "EuclideanLoss"
bottom: "ampl"
bottom: "label1"
top: "loss1"
}
...
layer {
name: "loss2"
type: "EuclideanLoss"
bottom: "ampl"
bottom: "label2"
top: "loss2"
}
Am I in the right direction?
AFAIK Caffe stores binary Datums in lmdb. The way Datum is defined restricts it to a single integer label per input image. Therefore it can be very tricky to use "Data" layer with lmdb in your scenario.
On the other hand you can use "HDF5Data" layer instead: this layer is much more flexible and can easily provide with more than a single label per input image. There are several examples here at SO on how to use this input layer, see, e.g. this answer.

Define center of map in Mapbox

I'm creating a viewer using Mapbox, the viewer will be full screen. However one half of the screen will be covered with a floating UI component. Therefor if the map zooms to a feature it should position the feature in the center of the other half of the screen. What would be a good way to approach this?
Currently when I zoom to a feature it will look like this, covered by the UI component:
I want it to automatically center on one half of the viewer, like this:
The fitBounds method allows you to pass an option for padding, for example:
map.fitBounds([[min_lon, min_lat], [max_lon, max_lat]], {
padding: {
top: 5,
bottom: 5,
left: 5,
right: document.getElementById('your_div').offsetWidth + 5
},
linear: true,
duration: 0
});

angular-nvd3 margin doesn't work? (krispo)

No matter how much I change the margin. The dates get cut off. I am trying to show a 7 date range, but the last date gets cut off. Any ideas, to work around this?
My code:
vm.lineChartOptions = {
chart: {
type: 'lineChart',
height: 450,
tickPadding: 25,
margin: {
top: 50,
right: 1000,
bottom: 60,
left: 1000
}
}
There's a property in the xAxis object, and I had the showMaxMin: set to false, and changed it to true. I also realized my gulp wasn't running for about an hour so there's that.
After I set to showMaxMin to true, and booted my gulp up again, I was able to change the margin.

ECharts: Multiple series (lines) with own yAxis

I want to switch from Highcharts to ECharts (preferably 3), but my current graphs have multiple series ('lines' in my case), with each their own yaxis, and it seems ECharts doesn't support this.
These metrics do not relate at all, so they all need their own yaxis. I combine them in 1 chart so they can be compared relative to each other (500 visits, €30000, 3% conversion.. etc). It makes no sense to plot 500 visits and 3% conversion rate on the same yaxis.
Is there a way to give each line it's own yaxis? It doesn't have to be a visible one (since there can only be two with ECharts, left/right of canvas, and that's ok), but the data needs to be plotted to an individual axis.
try this
yAxis: [
{
type: 'value',
name: 'left_yaxis',
nameTextStyle: {
color: '#fff'
},
splitLine:{
show:false,
},
axisLabel: {
textStyle:{
color:'#fff',
}
}
},
{
type: 'value',
name: 'right_yaxis',
nameTextStyle: {
color: '#fff'
},
axisLabel: {
interval:'0',
textStyle:{
color:'#fff',
}
},
splitLine: {
lineStyle: {
color: ['#454545'],
}
},
min:0,
//max:800000,
splitNumber:5
}
],
Here ar example from echarts for dual y axis:
example 1
example 2
You can add more than one y axis in echarts by making yaxis element as a array
Yes, ECharts supports multi-axis. See example at ECharts Gallery.

Embed bubble charts on a web site

I'm looking for a way to create what come to know to be called a "bubble chart" for a website I'm building. It needs to be compatible with IE7 and above, and of course all the good browsers like Firefox, Chrome and Safari. And no flash since this thing will need to run on iOS.
The chart needs to look like this, http://www.flickr.com/photos/jgrahamthomas/5591441300/
I've browse online and tried a few things, including:
Google Scatter Charts. This doesn't work as it seems Google Charts limits the size of a point to something smaller than I need. And Venn Diagrams are limited to three circles.
Protovis Dots. Great library, but isn't compatible with IE8.
Raphael Javascript. This one might be my best bet, but there's no explicit support for bubble charts.
Thanks for your help.
It looks like Raphael javascript is the way to go. It's compatible with IE6. I found a great tutorial at http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ and am able to get the example working on my rails site with this code:
# window.onload = function() {
# var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);
# var circle = paper.circle(100, 100, 80);
# for(var i = 0; i < 5; i+=1) {
# var multiplier = i*5;
# paper.circle(250 + (2*multiplier), 100 + multiplier, 50 - multiplier)
# }
# var rectangle = paper.rect(200, 200, 250, 100);
# var ellipse = paper.ellipse(200, 400, 100, 50);
# }
You can give Protovis a chance, the library looks good for your needs: http://vis.stanford.edu/protovis/ex/
Another charting library is Highcharts, but I haven't tried it yet: http://www.highcharts.com/
Have you had a look at flot?
It's a plotting library for jQuery. While it technically doesn't have any "native" support for bubble charts it is possible to create bubble charts with it by using a few tricks, the simplest one probably being to simply put each point in its own data series (thus allowing you to control the radius of each individual point.
By defining your points similar to this you'll be able to create a bubble chart:
var dataSet = [{
color:"rgba(0,0,0,0)", // Set the color so it's transparent
shadowSize:0, // No drop shadow effect
data: [[0,1],], // Coordinates of the point, normally you'd have several
// points listed here...
points: {
show:true,
fill:true,
radius: 2, // Here we set the radius of the point (or rather, all points
// in the data series which in this case is just one)
fillColor: "rgba(255,140,0,1)", // Bright orange :D
}
},
/* Insert more points here */
];
There is a bubble chart available for flot here
Note that you need to scale your bubbles size yourself if you don't want them to coverup the graph. Documentation is here.
To use it, add the following at the beggining of your html page:
and call it from a json result or any data object like in this sample:
$.getJSON('myQuery.py?'+params, function(oJson) {
// ... Some validation here to see if the query worked well ...
$.plot('#myContainer',
// ---------- Series ----------
[{
label: 'Line Sample',
data: oJson.lineData,
color: 'rgba(192, 16, 16, .2)',
lines: { show: true },
points: { show: false }
},{
label: 'Bubble Sample',
data: oJson.bubbleData, // arrays of [x,y,size]
color: 'rgba(80, 224, 80, .5)',
lines: { show: false },
points: { show: false },
},{
label: 'Points sample',
data: oJson.pointsData,
color: 'rgba(255, 255, 0, 1)',
lines: { show: false },
points: { show: true, fillColor: 'rgba(255, 255, 0, .8)' }
},{
...other series
}],
// ---------- Options ----------
{ legend: {
show: true,
labelBoxBorderColor: 'rgba(32, 32, 32, .2)',
noColumns: 6,
position: "se",
backgroundColor: 'rgba(224, 224, 224, .2)',
backgroundOpacity: .2,
sorted: false
},
series: {
bubbles: { active: true, show: true, fill: true, linewidth: 2 }
},
grid: { hoverable: true, clickable: true } },
xaxis: { tickLength: 0 }
}); // End of plot call
// ...
}); // End of getJSON call
I tried to do the same thing with jqPlot which has some advantages but doesn't work with bubbles and other kind of series on the same graph. Also Flot does a better job to synchronise common axis scale with many series. Highchart does a really good job here (mixing bubble chart with other kind of series) but isn't free for us (government context).