Skip to content

Instantly share code, notes, and snippets.

/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
///*M///////////////////////////////////////////////////////////////////////////////////////
//
@berak
berak / 5_convolutional_net.py
Last active July 3, 2017 12:39
tensorflow
import cv2
import numpy as np
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
def init_weights(shape):
return tf.Variable(tf.random_normal(shape, stddev=0.01))
def model(X, w_h, w_o):
@berak
berak / recurrent_network.py
Last active July 3, 2017 12:39
tensorflow
'''
A Reccurent Neural Network (LSTM) implementation example using TensorFlow library.
This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/)
Long Short Term Memory paper: http://deeplearning.cs.cmu.edu/pdfs/Hochreiter97_lstm.pdf
Author: Aymeric Damien
Project: https://github.com/aymericdamien/TensorFlow-Examples/
'''
import cv2
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data as input_data
@berak
berak / cifar10.py
Created December 13, 2015 19:33
tensorflow
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@berak
berak / att.py
Last active December 18, 2015 09:31
import cv2
import numpy as np
import tensorflow as tf
def asRow(X):
"""
Creates a row-matrix from multi-dimensional data items in list l.
X [list] List with multi-dimensional data.
#include "opencv2/opencv.hpp"
using namespace cv;
#include <iostream>
using namespace std;
//
// b g r y cr cb h s v like pearls ona string.
//
Mat feature(const Vec3b &pixel) {
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
Mat im_hsv;
void pick_color(int e, int x, int y, int s, void *)
{
if (e==1)
{
// http://answers.opencv.org/moderation-queue/
var inp = document.getElementsByTagName("input")
for (i=0; i<inp.length; i++) {
if (inp[i].type == "checkbox") {
inp[i].checked = true;
}
}
@berak
berak / ROC opencv
Created December 25, 2016 08:08
ROC opencv
namespace ROC {
void curve(const Mat &probs, const Mat &truth, vector<Point2f> &roc, int N, const float eps=1e-1) {
for (int i=0; i<N; i++) {
float thresh = float(N-i) / N;
float TP = countNonZero((probs > thresh) & (truth > eps));
float TN = countNonZero((probs <= thresh) & (truth <= eps));
float FP = countNonZero((probs > thresh) & (truth <= eps));
float FN = countNonZero((probs <= thresh) & (truth > eps));
float FPR = FP / (FP + TN);
float TPR = TP / (TP + FN);
@berak
berak / blink.cpp
Last active December 29, 2016 10:37 — forked from sarmadm/blink.cpp