Skip to content

Instantly share code, notes, and snippets.

View ilyakava's full-sized avatar

Ilya Kavalerov ilyakava

View GitHub Profile
@ilyakava
ilyakava / ima_image_links
Created March 5, 2015 21:15
Ima images links
#include <stdio.h>
__global__ void cube(float * d_out, float * d_in){
// Todo: Fill in this function
int idx = threadIdx.x;
float f = d_in[idx];
d_out[idx] = f * f * f;
}
int main(int argc, char ** argv) {
# On: Ubuntu 14.10 (Utopic Unicorn), used with opencv 2.4.11 and cuda-7.0 for Quadro NVS 510
# Also successfuly tested On: Ubuntu 14.10 (Utopic Unicorn), used with opencv 3.0.0 and cuda-7.0 for Tesla K40c
set -o errexit
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev
echo "Installing ffmpeg from source"
sudo apt-get -qq install git
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
"""
This tutorial introduces logistic regression using Theano and stochastic
gradient descent.
Logistic regression is a probabilistic, linear classifier. It is parametrized
by a weight matrix :math:`W` and a bias vector :math:`b`. Classification is
done by projecting data points onto a set of hyperplanes, the distance to
which is used to determine a class membership probability.
Mathematically, this can be written as:
@ilyakava
ilyakava / mlp.py
Last active August 29, 2015 14:21
"""
This tutorial introduces the multilayer perceptron using Theano.
A multilayer perceptron is a logistic regressor where
instead of feeding the input to the logistic regression you insert a
intermediate layer, called the hidden layer, that has a nonlinear
activation function (usually tanh or sigmoid) . One can use many such
hidden layers making the architecture deep. The tutorial will also tackle
the problem of MNIST digit classification.
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_WIDTH 1000
void print_array(int *array, int size)
{
printf("{ ");
for (int i = 0; i < size; i++) { printf("%d ", array[i]); }
printf("}\n");
@ilyakava
ilyakava / epub.sh
Created August 2, 2015 12:02
Input an arg of a file of a list of links, get an output.epub of all those webpages concatenated
#!/bin/bash
COUNT=1
for link in $(cat $1)
do
wget -O - -o /dev/null $link | iconv -f iso8859-1 -t utf-8 > $COUNT.html
COUNT=$(echo $COUNT + 1 |bc)
done
# assumes the images have been downloaded from imagenet and are named:
# bird.tar car.tar circle.tar flower.tar horse.tar house.tar mountain.tar tree.tar woman.tar
TAGS=( car tree circle house mountain bird flower horse woman )
# total=7577
LIMS=( 738 797 836 839 849 853 856 895 914 )
# list contents of tarballs and shave off file extension
for tag in "${TAGS[@]}"; do tar -tf $tag.tar | sed 's/.JPEG$//' > $tag.txt; done
# append my chosen class numbers for each class (hand is the missing #2)
import matplotlib
matplotlib.use('Agg')
from skimage.io import imread
matplotlib.rcParams.update({'font.size': 2})
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid
import sys
import numpy as np
import scipy.ndimage as nd