Skip to main content

zChainer

scikit-learn like interface and stacked autoencoder for chainer

Installation

pip install zChainer

Usage

Autoencoder

import numpy as np
import chainer.links as L
from chainer import ChainList, optimizers
from zChainer import NNAutoEncoder, utility

data = (..).astype(np.float32)

encoder = ChainList(
    L.Linear(784, 1000),
    L.Linear(1000, 100))
decoder =(
    L.Linear(1000, 784),
    L.Linear(100, 1000))

ae = NNAutoEncoder(encoder, decoder, optimizers.Adam(), epoch=2, batch_size=100,
    log_path="./ae_log_"+utility.now()+".csv", export_path="./ae_"+utility.now()+".model")

ae.fit(data)

Training and Testing

import numpy as np
import chainer.functions as F
import chainer.links as L
from chainer import ChainList, optimizers
from zChainer import NNManager, utility
import pickle

X_train = (..).astype(np.float32)
y_train = (..).astype(np.int32)
X_test = (..).astype(np.float32)
y_test = (..).astype(np.int32)

# Create a new network
model = ChainList(L.Linear(784, 1000), L.Linear(1000, 100), L.Linear(100, 10))

# or load a serialized model
#f = open("./ae_2015-12-01_11-26-45.model")
#model = pickle.load(f)
#f.close()
#model.add_link(L.Linear(100,10))

def forward(self, x):
    h = F.relu(self.model[0](x))
    h = F.relu(self.model[1](h))
    return F.relu(self.model[2](h))
NNManager.forward = forward

nn = NNManager(model, optimizers.Adam(), F.softmax_cross_entropy, epoch=10, batch_size=100,
    log_path="./training_log_"+utility.now()+".csv", export_path="./training_"+utility.now()+".model")

nn.fit(X_train, y_train, X_test, y_test)
nn.predict(X_test)

Metadata

Release files for zChainer 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zChainer 0.1.1
File Size Uploaded Provenance Actions
zChainer-0.1.1.tar.gz 3.4 kB Without provenance Details for zChainer-0.1.1.tar.gz

Release files / zChainer-0.1.1.tar.gz

Download URL zChainer-0.1.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f70bdfa4ee47dab06608636c67b6e2ccc36a074c245a1a43cce795e3a46345b4
BLAKE2b-256 checksum
How to use checksums
24db7c14591816f10695339e9a9a793a9edbb3674d7cf6f6ba15df0c621c7337
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for zChainer 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page