Posts

Showing posts from August, 2017

[Caffe] How to use Caffe to solve the regression problem?

Image
There is a question coming up to my mind recently. How to use Caffe to solve the regression problem? We used to see a bunch of examples related to image recognition with labels and they are classification problem. In my experience, I have done this problem using TensorFlow, not Caffe. But, I think in theory they are both the same. The key point is using EuclideanLossLayer as the final Loss Layer and it's the detail from the official web site:

http://caffe.berkeleyvision.org/doxygen/classcaffe_1_1EuclideanLossLayer.html#details
"This can be used for least-squares regression tasks. An InnerProductLayer input to a EuclideanLossLayer exactly formulates a linear least squares regression problem. With non-zero weight decay the problem becomes one of ridge regression – see src/caffe/test/test_sgd_solver.cpp for a concrete example wherein we check that the gradients computed for a Net with exactly this structure match hand-computed gradient formulas for ridge regression. (Note: Caffe, a…

[Raspberry Pi] Use Wireless and Ethernet together

The following content is my Raspberry Pi 3's setting in /etc/network/interface as follows. In my case, I both use wireless and ethernet device at the same time.
# Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto wlan0 allow-hotplug wlan0 iface wlan0 inet manual Wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug eth0 iface eth0 inet static address 140.96.29.224 netmask 255.255.255.0 up ip route add 100.85.0.0/24 via 140.96.29.254 dev eth0 up ip route add 140.96.29.0/24 via 140.96.29.254 dev eth0 up ip route add 140.96.98.0/24 via 140.96.29.254 dev eth0
But, this situation will encounter routing problem like this ( There are two default gateways):
I only want the 2nd one.
pi@raspberrypi:~ $ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 140.96.29.254 0.0.0.0 UG 202 0 0 eth0…

[Debug] Debugging Python and C++ exposed by boost together

During the studying of Caffe, I was curious about how Caffe provides Python interface and what kind of tool uses for wrapping. Then, the answer is Boost.Python. I think for C++ developer, it is worth time to learn and I will study it sooner. In this post, I want to introduce the debugging skill which I found in this post and I believe these are very useful such as debugging Caffe with Python Layer. Here is the link:
https://stackoverflow.com/questions/38898459/debugging-python-and-c-exposed-by-boost-together

And it provides a useful approach to deal with this kind of debugging Python and C++ together as follows: http://www.boost.org/doc/libs/1_61_0/libs/python/doc/html/faq/how_do_i_debug_my_python_extensi.html

I use its way to try debugging a little bit and it works well. Here is a simple example using Caffe Python.

$ gdb python (gdb) target exec python (gdb) run >>> import caffe >>> [C-c] # Ctrl + C (gdb) break caffe::set_mode_cpu() # Please refer to $(CAFFE_ROO…