Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block nnop

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
class DataProvider(object):
def __init__(self,label_dict, top_blobs = None):
# for determinist evaluation
self.random_state = None
self.label_dict = label_dict
if top_blobs is None:
x = label_dict.values()[0]
if type(x) == int:
self.top_blobs = ["img", "label"]

How to create a custom Caffe layer in Python?

This tutorial will guide through the steps to create a simple custom layer for Caffe using python. By the end of it, there are some examples of custom layers.

- Why would I want to do that?

Usually you would create a custom layer to implement a funcionality that isn't available in Caffe, tuning it for your requirements.

- What will I need?

Probably just Python and Caffe installed.

- Is there any downside?

# coding: utf-8
# A little demo illustrating the effect of momentum in neural network training.
# Try using different values for MOMENTUM constant below (e.g. compare 0.0 with 0.9).
# This neural network is actually more like logistic regression, but I have used
# squared error to make the error surface more interesting.
import numpy as np
import pylab
# A yaml constructor is for loading from a yaml node.
# This is taken from @misha 's answer:
def opencv_matrix_constructor(loader, node):
mapping = loader.construct_mapping(node, deep=True)
mat = np.array(mapping["data"])
mat.resize(mapping["rows"], mapping["cols"])
return mat
yaml.add_constructor(u",2002:opencv-matrix", opencv_matrix_constructor)
# A yaml representer is for dumping structs into a yaml node.
ducha-aiki / cifar10_full_sigmoid_solver.prototxt
Created Oct 22, 2015
Examples of how to use batch_norm in caffe
View cifar10_full_sigmoid_solver.prototxt
# The train/test net protocol buffer definition
net: "examples/cifar10/cifar10_full_sigmoid_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of CIFAR10, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 100
# Carry out testing every 1000 training iterations.
test_interval: 1000
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.001
beci / gcc 5 on ubuntu 14.04
Created Oct 15, 2015
use gcc 5.x on ubuntu 14.04
View gcc 5 on ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
benjbaron / QGraphicsSceneTest.cpp
Last active Oct 15, 2019
Qt QGraphicsScene click, select, move, resize, delete QGraphicsItems
View QGraphicsSceneTest.cpp
#include <QtGui>
#include <QGraphicsRectItem>
#include <QGraphicsView>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
class CustomItem : public QGraphicsEllipseItem
void mousePressEvent(QGraphicsSceneMouseEvent *event)
dulacp /
Last active Dec 7, 2019
Download & Compile Libpng for iOS (all architectures)
# Builds a Libpng framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libpng in Xcode
# less painful.
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
# Then go get the source of the libpng you want to build, shove it in the
# same directory as this script, and run "./". Grab a cuppa. And voila.
sloria /
Created Oct 16, 2013
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General


  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
spicycode / tmux.conf
Created Sep 20, 2011
The best and greatest tmux.conf ever
View tmux.conf
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
You can’t perform that action at this time.