This file contains 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
# Written by Yuta Koreeda | |
# CC-BY | |
import numpy as np | |
class ExtremeLearningMachine(object): | |
def __init__(self, n_unit, activation=None): | |
self._activation = self._sig if activation is None else activation | |
self._n_unit = n_unit |
This file contains 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
###### Editor debris ######## | |
*.org | |
*~ | |
¥#* | |
# spyder | |
.spyderproject/ | |
# pycharm |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 | |
import chainer.functions as F | |
import chainer.links as L | |
from chainer import training | |
from chainer.training import extensions | |
# Network definition | |
class MLP(chainer.Chain): | |
def __init__(self, n_out): | |
super(MLP, self).__init__() |
This file contains 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
def lock(f): | |
""" decorator which locks class method | |
You need property _lock defined as in the following. | |
self._lock = threading.Lock() | |
""" | |
def body(self, *args, **kwargs): | |
with self._lock: | |
return f(self, *args, **kwargs) | |
return body |
This file contains 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
@contextlib.contextmanager | |
def safe_mkdir(path, dir=None): | |
""" Create a directory in safe(r) way. Specified directory is created only when | |
whole operations in `with` scoped is completed successfully. All the files | |
that are created within the temporaly generated dir will be kept within. | |
This may not work in some OS. | |
""" | |
if dir is None: | |
dir = os.path.dirname(path) |
This file contains 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
def sequence_mask(x, length, value=0.): | |
xp = cuda.get_array_module(length.data) | |
# create permutation on (length.ndim + 1) dimension and expand dims until it has shame rank as x | |
perms = xp.arange(x.shape[length.ndim]).reshape( | |
[1] * length.ndim + [-1] + [1] * (x.ndim - length.ndim -1)) | |
length = length.reshape([1] * (length.ndim - 1) + [-1] + [1] * (x.ndim - length.ndim)) | |
pad = xp.ones_like(x) * value | |
mask = xp.broadcast_to(perms, x.shape) < length | |
return F.where(mask, x, pad) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
<div style="background-image: linear-gradient(bottom, #FFD51A 50%, #FAC815 50%); | |
background-image: -o-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -moz-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -webkit-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -ms-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
display: inline-block;">aaaa</div> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer