Skip to content

Instantly share code, notes, and snippets.

View joao-timescale's full-sized avatar

João joao-timescale

View GitHub Profile
@joao-timescale
joao-timescale / filapri.c
Created November 13, 2016 04:27
Min-Priority Queue using a binary heap
#include <malloc.h>
#include "filapri.h"
static inline int pri_menor(filapri f, size_t ind_a, size_t ind_b);
static inline void troca_nodo(filapri f, size_t ind_a, size_t ind_b);
static void arruma_heap_up(filapri f);
static void arruma_heap_down(filapri f, size_t k);
int pri_menor(filapri f, size_t ind_a, size_t ind_b)
{
import logging, theano
logging.basicConfig(format="%(asctime)s:%(levelname)s:%(name)s: %(message)s")
theano.disable_log_handler()
theano.theano_logger.warning("foo") # Usually it's a library function that does this.
@joao-timescale
joao-timescale / ctc_test.cu
Created June 9, 2017 22:12
CTC Torch test
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <cuda_runtime.h>
#include "ctc.h"
#define CTC_CHECK(expr) abort_on_error((expr), __LINE__, __func__)
#define CUDA_CHECK(expr) cuda_abort_on_error((expr), __LINE__, __func__)
======================================================================
ERROR: theano.gpuarray.tests.test_dnn.test_dnn_spatialtf_grad
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jvtr/miniconda3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/jvtr/repos/Theano/theano/gpuarray/tests/test_dnn.py", line 2527, in test_dnn_spatialtf_grad
utt.verify_grad(functor_wrt_i, [img])
File "/home/jvtr/repos/Theano/theano/tests/unittest_tools.py", line 91, in verify_grad
T.verify_grad(op, pt, n_tests, rng, *args, **kwargs)
@joao-timescale
joao-timescale / spatialt_grad_test.py
Last active August 21, 2017 15:01
Test spatial transformer gradients
import numpy as np
import theano
import theano.printing
import theano.tensor as T
from theano.tests import unittest_tools as utt
from theano.tensor.nnet.abstract_spatialtf import (AbstractSpatialTransformerGradIOp, AbstractSpatialTransformerGradTOp)
from theano.tensor.nnet.spatialtf import (spatialtf, spatialtf_cpu)
from theano.gpuarray import dnn
from theano.compile.debugmode import DebugMode
@joao-timescale
joao-timescale / final_report.md
Last active August 29, 2017 04:08
GSoC 2017 - Final Submission

Google Summer of Code 2017 - Final Report

Author: João Victor Tozatti Risso

Date of Submission: 2017-08-28

Organization: Python Software Foundation

Suborganization: Theano

@joao-timescale
joao-timescale / knn.py
Last active November 26, 2017 12:36
k-nearest neighbors algorithm
import numpy as np
from scipy.stats import mode
from scipy.spatial import KDTree
class KNearestNeighbors(object):
def __init__(self, k=1):
assert k >= 1
self.__k = int(k)
@joao-timescale
joao-timescale / knn_dataset.py
Created November 26, 2017 12:37
KNN Dataset
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt
# Load data set and corresponding labels
digits_data = load_digits()
digits = digits_data.data
labels = digits_data.target
class_names = digits_data.target_names
# Partition data set into training and test data sets
@joao-timescale
joao-timescale / knn_training.py
Created November 26, 2017 12:40
KNN training
classifier = KNearestNeighbors(k=5)
# Train the classifier
classifier.fit(train_data, train_data_labels)
# Obtain the predictions based on the training data
prediction = classifier.predict(test_data)
@joao-timescale
joao-timescale / knn_confusionmat.py
Created November 26, 2017 12:41
k-NN confusion matrix
from sklearn.metrics import confusion_matrix
cnf_matrix = confusion_matrix(test_data_labels, prediction)