Skip to content

Instantly share code, notes, and snippets.

View akiross's full-sized avatar
🥷
Ninja

Alessandro Re akiross

🥷
Ninja
View GitHub Profile
@akiross
akiross / affines.go
Created June 8, 2016 01:13
Affine transformations in go
package main
// This example shows how affine transformations can be combined yielding
// a single matrix which represent complex transformations.
// Feed the output into gnuplot to see the points:
// go build affines.go
// ./affines | gnuplot -p -e "plot '-' u 1:2:3 w p pt 7 palette"
import (
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akiross
akiross / Convolutional Arithmetic.ipynb
Last active October 24, 2024 07:04
Few experiments on how convolution and transposed convolution (deconvolution) should work in tensorflow.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akiross
akiross / zshrc
Created January 13, 2017 16:35
A very handy function to auto-activate specific python virtual environments upon entering a directory containing a magic file.
# Setup python virtual environment in a given directory subtree
function chpwd_auto_pyvenv() {
local MAGIC=".zsh_pyvenv"
# Check if we encountered a magic previously
if [[ -z ${ZSH_PYVENV_PARENT+x} ]]; then
# Check if this directory contains a MAGIC
if [[ -a "$PWD/$MAGIC" ]]; then
echo "Activating virtual environment"
# Activate the environment specified
@akiross
akiross / google_hash_code_deap.py
Created February 23, 2017 21:40
Google Hash Code 2017 - Youtube video caching solution using Genetic Algorithms
#!/usr/bin/env python3
'''So, I entered the Google Hash Code 2017 competition with a team named PiedPiper,
with a guy from UK and a girl from Palestine, but in the end each one of us worked
in her/his own. I came up with a solution using Genetic Algorithms (via DEAP).
I used the score function to build an algorithm that used 1-bit encodings to represent
the presence of a video over a certain cache server.
I wasted some time during the competition, so I managed to run briefly the algo on the
@akiross
akiross / autoencoder.ipynb
Created March 22, 2017 12:04
Super-simple autoencoder with tensorflow and MNIST data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akiross
akiross / Understanding_queues_in_TF.ipynb
Created April 3, 2017 16:50
This notebook aims to explain how queues are used in tensorflow, in a bit more practical way than the official docs. I developed and tested this with TF 1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akiross
akiross / pigreco.cu
Last active February 17, 2025 23:07
Approximate Pi using usual Monte-Carlo simulation, in CUDA (with bonus Python snippet!).
// Approximation of Pi using a simple, and not optimized, CUDA program
// Copyleft Alessandro Re
//
// GCC 6.x not supported by CUDA 8, I used compat version
//
// nvcc -std=c++11 -ccbin=gcc5 pigreco.cu -c
// g++5 pigreco.o -lcudart -L/usr/local/cuda/lib64 -o pigreco
//
// This code is basically equivalent to the following Python code:
//
@akiross
akiross / prime_numbers.py
Created July 6, 2017 12:06
Generating prime numbers in chunks
def extend(old, new):
for p in old:
cand = []
for n in new:
if n % p != 0:
cand.append(n)
if not cand:
return old
old.append(cand[0])
new = cand[1:]
@akiross
akiross / pandas_data_index.py
Created July 18, 2017 07:54
Simple example on using dates as index
#!/usr/bin/env python3
import pandas as pd
import io
# Make up some data
example_csv = '''Birthday,Name,Surname
1643-01-04,Isaac,Newton
1879-03-14,Albert,Einsten
1942-01-08,Stephen,Hawking