Skip to main content

Deep learning model adapter, used to quickly create various deep learning models.

Project description

image ZWell-model

A deep learning model library that supports various deep network models and transformations to libraries such as Keras. With this tool, it is easy to construct neural network objects that can be used for any API, saving additional API learning time.

Usage examples

There are many neural network implementations in this library that support conversion to various library model objects. The following are relevant examples.

Basic Convolutional Neural Networks

The basic convolutional neural network contains the most basic network structure, which compromises learning speed and accuracy, and has two versions in total.

first edition

A convolutional neural network with learning speed as its main core can improve learning speed for a large amount of data with almost identical features.

import zWell_model

# Obtaining the first type of convolutional neural network
resNet = zWell_model.conv_net1.ConvNetV1(
    # The number of additional convolutional layers to be added above the specified infrastructure is 4. TODO defaults to 1
    model_layers_num=4,
    # Specify the step size in the four convolutional layers
    stride=[1, 2, 1, 2],
    # Specify the input dimension of convolutional neural networks
    input_shape=(None, 32, 32, 3),
    # Specify classification quantity
    classes=10
)

Second Edition

The convolutional neural network, whose core is learning speed and preventing overfitting, can improve learning speed and model accuracy for a large number of data with diversified features.

import zWell_model

# Obtaining the second type of convolutional neural network
resNet = zWell_model.conv_net2.ConvNetV2(
    # The number of additional convolutional layers to be added above the specified infrastructure is 1. TODO defaults to 1
    model_layers_num=1,
    # Specify the step size in the one convolutional layers
    stride=[1],
    # Specify the input dimension of convolutional neural networks
    input_shape=(32, 32, 3),
    # Specify classification quantity
    classes=10
)

Example of using basic convolutional neural networks

What is displayed here is the operation of converting the basic convolutional neural network series into models in Keras and calling them.

# This is an example Python script.
import numpy as np
from keras.datasets import cifar10
from keras.optimizers import Adam
from livelossplot import PlotLossesKeras

import zWell_model

# Obtaining a dataset
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
# Data standardization and dimension expansion
x_train = x_train.astype(np.float32).reshape(-1, 32, 32, 3) / 255.
x_test = x_test.astype(np.float32).reshape(-1, 32, 32, 3) / 255.

# Obtaining the second type of convolutional neural network
resNet = zWell_model.conv_net2.ConvNetV2(
    # The number of additional convolutional layers to be added above the specified infrastructure is 1. TODO defaults to 1
    model_layers_num=1,
    # Specify the step size in the one convolutional layers
    stride=[1],
    # Specify the input dimension of convolutional neural networks
    input_shape=(32, 32, 3),
    # Specify classification quantity
    classes=10
)

# Converting to the network model of Keras
model = resNet.to_keras_model()
model.summary()

# Start building the model
model.compile(
    loss='sparse_categorical_crossentropy',
    optimizer=Adam(learning_rate=0.001),
    metrics=['acc']
)

# Start training the model
model.fit(
    x=x_train, y=y_train,
    validation_data=(x_test, y_test),
    batch_size=32, epochs=30,
    callbacks=[PlotLossesKeras()],
    verbose=1
)

Residual neural network

You can obtain the general object of the residual neural network object from ZWell model in the following way.

import zWell_model

# Obtaining residual neural network
resNet = zWell_model.res_net.ResNet(
    # Specify the number of residual blocks as 4 TODO defaults to 4
    model_layers_num=4,
    # Specify the number of output channels in the four residual blocks
    k=[12, 12, 12, 12],
    # Specify the step size in the four residual blocks
    stride=[1, 2, 1, 2],
    # Specify the input dimension of the residual neural network
    input_shape=(32, 32, 3),
    # Specify classification quantity
    classes=10
)

Directly convert the obtained residual neural network object into a neural network model object in Keras, enabling it to be supported by Keras.

# This is an example Python script.
import numpy as np
from keras.datasets import cifar10
from keras.optimizers import Adam
from livelossplot import PlotLossesKeras

import zWell_model

# Obtaining a dataset
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
# data standardization
x_train, x_test = x_train.astype(np.float32) / 255., x_test.astype(np.float32) / 255.

# Obtaining residual neural network
resNet = zWell_model.res_net.ResNet(
    # Specify the number of residual blocks as 4 TODO defaults to 4
    model_layers_num=4,
    # Specify the number of output channels in the four residual blocks
    k=[12, 12, 12, 12],
    # Specify the step size in the four residual blocks
    stride=[1, 2, 1, 2],
    # Specify the input dimension of the residual neural network
    input_shape=(32, 32, 3),
    # Specify classification quantity
    classes=10
)

# Converting to the network model of Keras
model = resNet.to_keras_model()
model.summary()

# Start building the model
model.compile(
    loss='sparse_categorical_crossentropy',
    optimizer=Adam(learning_rate=0.001),
    metrics=['acc']
)

# Start training the model
model.fit(
    x=x_train, y=y_train,
    validation_data=(x_test, y_test),
    batch_size=32, epochs=30,
    callbacks=[PlotLossesKeras()],
    verbose=1
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zWell_model-0.0.1.20230514.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

zWell_model-0.0.1.20230514-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file zWell_model-0.0.1.20230514.tar.gz.

File metadata

  • Download URL: zWell_model-0.0.1.20230514.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for zWell_model-0.0.1.20230514.tar.gz
Algorithm Hash digest
SHA256 9e5a2fe3f357852136676f9ff5ac49e5bdec342bf57b5e89e49419da8e628b3b
MD5 70f2da478b26a8e4756aac2a0c80aebe
BLAKE2b-256 6dc4bdceb2fdeeaeec73b26065819719e08d19cf16cd683b68321919aa0e2708

See more details on using hashes here.

File details

Details for the file zWell_model-0.0.1.20230514-py3-none-any.whl.

File metadata

File hashes

Hashes for zWell_model-0.0.1.20230514-py3-none-any.whl
Algorithm Hash digest
SHA256 70c1cf5ead11a1d2129ea8a166c1b92c4f73f11220c0d9e98abb57d1415b5340
MD5 3015812832511a9b1d4a49f7c7ba3dc6
BLAKE2b-256 b82eca643417fa0174903be98b3c318ff2fcb93ee516d8c3c6b46d6192eb0344

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page