Skip to content

Instantly share code, notes, and snippets.

View JulesBelveze's full-sized avatar

Jules Belveze JulesBelveze

View GitHub Profile
@SuperShinyEyes
SuperShinyEyes / f1_score.py
Created October 15, 2019 10:16
F1 score in PyTorch
def f1_loss(y_true:torch.Tensor, y_pred:torch.Tensor, is_training=False) -> torch.Tensor:
'''Calculate F1 score. Can work with gpu tensors
The original implmentation is written by Michal Haltuf on Kaggle.
Returns
-------
torch.Tensor
`ndim` == 1. 0 <= val <= 1
@fannix
fannix / load_and_save.py
Created February 18, 2012 08:34
Save and load sparse matrix
"""http://stackoverflow.com/questions/6282432/load-sparse-array-from-npy-file
"""
import random
import scipy.sparse as sparse
import scipy.io
import numpy as np
def save_sparse_matrix(filename, x):
x_coo = x.tocoo()
row = x_coo.row
@rkumar
rkumar / itunes.sh
Created August 1, 2010 09:23
control iTunes from command line
#!/bin/bash
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# edit 2010.06.01 rahul kumar
####################################
showHelp () {