Skip to content

Instantly share code, notes, and snippets.

View germank's full-sized avatar

Germán Kruszewski germank

  • Naver Labs Europe
View GitHub Profile
@germank
germank / logistic_regression_example.py
Created July 22, 2019 00:02
Logistic regression implementation
import numpy as np
import tqdm
import timeit
np.random.seed(42)
d = 100
N = 1000
# gold value
w_star = np.random.randn(d)
b_star = np.random.randn(1)
import matplotlib.pyplot as plt
# reporting the best results per-team (and top 10)
data ={'2011':
[0.25770, 0.31010, 0.35960, 0.50450],
'2012':
[0.15315, 0.26172, 0.26979, 0.27058, 0.29576, 0.33419, 0.34464],
'2013':
[0.11197, 0.12953, 0.13511, 0.13555, 0.13748, 0.13985, 0.14182,
0.14291, 0.15193, 0.15245],
@germank
germank / ex2.py
Last active February 20, 2018 22:15
Code stub for a simple text classifier
# encoding=utf-8
# --- Adapted From ---
# Project: learn-pytorch
# Author: xingjunjie github: @gavinxing
# Create Time: 29/07/2017 11:58 AM on PyCharm
# Original code at: https://gist.github.com/GavinXing/9954ea846072e115bb07d9758892382c
import torch
import torch.nn as nn
import torch.autograd as autograd
@germank
germank / ex1.py
Last active December 18, 2017 16:03
Code stub for a simple word2vec model
import torch
import torch.nn as nn
from torch.autograd import Variable
class SimpleW2V(nn.Module):
def __init__(self, nwords, ncontexts, vec_size):
super(SimpleW2V, self).__init__()
# randomly initialized vectors
self.words_emb = nn.Embedding(nwords, vec_size)
@germank
germank / toggle_sink.py
Created September 8, 2016 07:13
Toggle the pulseaudio sink rotating between the available ones.
#!/usr/bin/env python
from subprocess import check_output, Popen, PIPE, call
import re
list_sinks = Popen(['pacmd', 'list-sinks'], stdout=PIPE)
output = str(check_output(['grep', r"index:"], stdin=list_sinks.stdout))
list_sinks.wait()
selected = None
sinks = []
for index_line in output.split(r'\n')[:-1]:
require 'torch'
require 'utils'
require 'math'
require 'table'
tablex = require 'pl/tablex'
TensorType = torch.Tensor
function copy(x)
return TensorType(x:size()):copy(x)