Skip to content

Instantly share code, notes, and snippets.

View corochann's full-sized avatar

corochann corochann

View GitHub Profile
@corochann
corochann / early_stopping_trigger.py
Last active November 6, 2017 09:40
Early stopping for Chainer using trainer extension.
from chainer import reporter
from chainer.training import util
class EarlyStoppingTrigger(object):
"""Early stopping trigger
It observes the value specified by `key`, and invoke a trigger only when
observing value satisfies the `stop_condition`.
@corochann
corochann / dataset_indexer_exp.ipynb
Last active August 25, 2017 02:09
Chainer dataset features accessing.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corochann
corochann / dataset_indexer_exp.py
Created August 21, 2017 04:39
Access Chainer dataset using indexer
import numpy as np
import chainer
from chainer.datasets import TupleDataset
train, test = chainer.datasets.get_mnist()
# 1. Extract data easily without explicitly call concat_examples
imgs, labels = train.ix[:, :]
#imgs, labels = train.ix[:] # same
@corochann
corochann / train_mnist_schedule_lr.py
Last active July 15, 2022 15:09
Manual Scheduling of optimizer's learning rate with Chainer trainer
from __future__ import print_function
import argparse
import chainer
import chainer.functions as F
import chainer.links as L
from chainer import training
from chainer.optimizers import MomentumSGD, Adam
from chainer.training import extensions, Trainer
from chainer import serializers
#!/usr/bin/env python
from __future__ import print_function
import argparse
import numpy as np
import matplotlib.pyplot as plt
import chainer
import chainer.functions as F
import chainer.links as L