Skip to content

Instantly share code, notes, and snippets.

Takuya Akiba iwiwi

Block or report user

Report or block iwiwi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View chance-level-ap.md
import numpy as np
from sklearn.metrics import average_precision_score

def chance_level_ap(n_all, n_positive, trials=1000):
    return np.mean([
        average_precision_score([1] * n_positive + [0] * (n_all - n_positive), np.random.permutation(n_all))
        for _ in range(trials)])
View chance-level-ap.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View qsub.py
#!/usr/bin/env python
import itertools
import sys
import os
import subprocess
import jinja2
def enumerate_combinations(**params):
View install_opencv.sh
#!/bin/bash
set -e
TARGET_DIR="$(dirname $(readlink -m $0))/.local"
WORKING_DIR="/tmp/"
LIBJPEG_VERSION="1.5.3"
OPENCV_VERSION="3.4.1"
eval "$(pyenv init -)"
PYENV_VERSION=$(pyenv version | cut -f 1 -d ' ')
View range_with_timeout.py
class RangeWithTimeout(object):
def __init__(self, n=None, timeout_seconds=None):
self.n = n
self.timeout_seconds = timeout_seconds
self.i = 0
def __iter__(self):
self.start_datetime = datetime.datetime.now()
View learning_rate_signal_handler.py
from chainer.training import extension
import signal
class LearningRateSignalHandler(extension.Extension):
trigger = 1, 'epoch'
def __init__(self, attr='lr', rate=0.1, signalnum=signal.SIGUSR1, optimizer=None):
self.attr = attr
@iwiwi
iwiwi / alltoall_demo.py
Created Aug 14, 2017
All-to-all collective communication for numpy & cupy arrays with ChainerMN (demo)
View alltoall_demo.py
import chainermn
from chainermn.communicators._memory_utility import array_to_buffer_object
import mpi4py.MPI
comm = chainermn.create_communicator('naive')
def alltoall_demo(xp):
mpi_comm = comm.mpi_comm
View rnn_forward.py
from typing import *
class Variable(object):
def __init__(self, data):
# type: (float) -> None
self.data = data
self.creator = None # type: Function
View selu.py
import chainer.functions as F
def selu(x, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946):
return scale * F.elu(x, alpha=alpha)
View numba_example.py
"""
(anaconda3-4.2.0) ~/tmp% python numba_example.py [18:00:09]
Python: 3.641503095626831
Numba: 0.09061694145202637
"""
import time
from numba import jit, int32
You can’t perform that action at this time.