This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import * | |
class Variable(object): | |
def __init__(self, data): | |
# type: (float) -> None | |
self.data = data | |
self.creator = None # type: Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chainer.functions as F | |
def selu(x, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946): | |
return scale * F.elu(x, alpha=alpha) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
(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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 普通の場合 | |
>>> class A: | |
... def hello(self): | |
... print('hellooooo') | |
... def __len__(self): | |
... print('lennnnnn') | |
... return 10 | |
... def __call__(self): | |
... print('calllllled') | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import sklearn.datasets | |
import sklearn.ensemble | |
import xgboost | |
N_TRAIN = 60000 | |
NS_ITERATIONS = [2 ** k for k in range(8)] | |
MODELS = [ | |
('RandomForestClassifier', sklearn.ensemble.RandomForestClassifier, {'n_jobs': -1}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* An xorshift random generator implementation, which is compatible to std::random. | |
* | |
* References: | |
* - http://cpplover.blogspot.jp/2013/03/blog-post_22.html | |
* - http://xorshift.di.unimi.it/xorshift64star.c | |
* - http://xorshift.di.unimi.it/xorshift1024star.c | |
*/ | |
#include <random> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Basic usage: | |
* $ CXXFLAGS=-O3 make shrink_ids | |
* $ ./shrink_ids < EDGES > SHRINKED_EDGES | |
* | |
* Example: | |
* $ echo "hoge piyo\nfuga hoge" | ./shrink_ids | |
* 0 1 | |
* 2 0 | |
* |