Skip to content

Instantly share code, notes, and snippets.

View iwiwi's full-sized avatar
🏠
Working from home

Takuya Akiba iwiwi

🏠
Working from home
View GitHub Profile
@iwiwi
iwiwi / jlog.py
Created June 5, 2016 02:25
Python implementation of JLOG (cpp-json-logger)
# Copyright 2016, Takuya Akiba
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
@iwiwi
iwiwi / alltoall_demo.py
Created August 14, 2017 05:32
All-to-all collective communication for numpy & cupy arrays with ChainerMN (demo)
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
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
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()
#!/usr/bin/env python
import itertools
import sys
import os
import subprocess
import jinja2
def enumerate_combinations(**params):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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)])
#!/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 ' ')
use crate::*;
mod normal_distribution {
const S2PI: f64 = 2.50662827463100050242E0;
// https://github.com/scipy/scipy/blob/v1.5.4/scipy/special/cephes/ndtri.c
const P0: [f64; 5] = [
-5.99633501014107895267E1,
9.80010754185999661536E1,
-5.66762857469070293439E1,
@iwiwi
iwiwi / WebGraphDecoder.java
Last active September 17, 2021 09:32
Download and decode WebGraph format graphs
import it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue;
import it.unimi.dsi.fastutil.ints.IntArrays;
import it.unimi.dsi.logging.ProgressLogger;
import it.unimi.dsi.webgraph.GraphClassParser;
import it.unimi.dsi.webgraph.ImmutableGraph;
import it.unimi.dsi.webgraph.LazyIntIterator;
import java.io.*;
import java.util.*;