Import


In [ ]:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import random

from sklearn.pipeline import Pipeline
from chainer import optimizers

from commonml.skchainer import MeanSquaredErrorRegressor, AutoEncoder

from tensorflow.contrib.learn import datasets

import logging
logging.basicConfig(format='%(levelname)s : %(message)s', level=logging.INFO)
logging.root.level = 20

Load Iris Data


In [ ]:
iris = datasets.load_iris()

Initialize a deep neural network autoencoder


In [ ]:
autoencoder = Pipeline([('autoencoder1',
                         AutoEncoder(4, 10, MeanSquaredErrorRegressor, dropout_ratio=0, optimizer=optimizers.AdaGrad(lr=0.1),
                                     batch_size=128, n_epoch=100, gpu=0)),
                        ('autoencoder2',
                         AutoEncoder(10, 20, MeanSquaredErrorRegressor, dropout_ratio=0, optimizer=optimizers.AdaGrad(lr=0.1),
                                     batch_size=128, n_epoch=100, gpu=0))])

Fit with Iris data


In [ ]:
transformed = autoencoder.fit_transform(iris.data)

print(transformed)