Deep-learning Designer: Deep-Learning Training Optimization & Layers API(like Keras)
Project description
[DDesigner API] Deep-learning Designer API
1. About
1.1. DDesignerAPI?
It is a API for deep-learning learning and inference, and an API for application development using multi-platform
1.2. Functions
1.2.1. Layers and Blocks
- Accelerator enabled layers and the ability to define special layers that are not defined in Keras and others
- A function that defines a combination of layers as a block and easily composes a block (ex. CONV + BN + ACT + DROPOUT= ConvBlock)
1.2.2. Optimization for Accelerator Usage (XWN)
- Optimized function to use accelerator
2. Support
2.1. Platforms
- Tensorflow 2.6.0
- PyTorch 1.13.1
2.2. Components of Network
2.2.1. Layers
- Accelerator enabled layers and Custom layers that perform specific functions
2.2.1.1. Summary
Operation | Support Train Platform | Support TACHY Accelerator |
---|---|---|
Convolution | TF / Keras / PyTorch | O |
TransposeConvolution | TF / Keras / PyTorch | O |
CascadeConvolution | Keras / PyTorch | O |
2.2.1.2. Detail
- Convolution : 1D, 2D with XWN optimization
- TransposeConvolution : 1D, 2D with XWN optimization
- CascadeConvolution : A Layer that decomposes a layer with large kernel into multiple layers with smaller kernels to lighten the model / 1D, 2D with XWN optimization
2.2.2. Blocks
- A set of defined layers for user convenience
2.2.2.1. Summary
Platform | ConvBlock | TConvBlock | FCBlock |
---|---|---|---|
TF-Keras | 1D/2D | 2D | TODO |
PyTorch | TODO | TODO | TODO |
2.2.2.2. Detail
- ConvBlock : Convolution N-D Block (CONV + BN + ACT + DROPOUT), support Conv1DBlock, Conv2DBlock
- TConvBlock : Transpose Convolution 2D Block (TCONV + BN + ACT + DROPOUT), support TConv2DBlock
- CascadeConvBlock : Cascade Convolution N-D Block (CONV + BN + ACT + DROPOUT), support CascadeConv1DBlock, CascadeConv2DBlock
2.3. XWN (Applies only to convolution operations)
2.3.1. Transform Configuration (data type / default value / description)
- transform : bool / False / Choose whether to use
- bit : int / 4 / Quantization range (bit-1 ** 2)
- max_scale : float / 4.0 / Max value
2.3.2. Pruning Configuration
- pruning : bool / False / Choose whether to use
- prun_weight : float / 0.5 / Weights for puning edge generation
2.3.3. Summary
Platform | Conv | TransposeConv | CascadeConv |
---|---|---|---|
TF | 1D/2D | 1D/2D | TODO |
Keras | 1D/2D | 1D/2D | TODO |
PyTorch | 1D/2D | 1D/2D | 1D/2D |
3. Command Usage
3.1. XWN
3.1.1. Single Convolution
3.1.1.1. Tensorflow
>>> from ddesigner_api.tensorflow.xwn import tf_nn as nn
>>> nn.conv2d(
x,
kernel,
...
use_transform=True,
bit=4,
max_scale=4.0,
use_pruning=False
)
3.1.1.2. Keras
>>> from ddesigner_api.tensorflow.xwn import keras_layers as klayers
>>> klayers.Conv2D(
2, 3,
...
use_transform=True,
bit=4,
max_scale=4.0
use_pruning=True,
prun_weight=0.5
)
3.1.1.3. PyTorch
>>> from ddesigner_api.pytorch.xwn import torch_nn as nn
>>> nn.Conv2d(
in_channels=1,
out_channels=2,
...
use_transform=True,
bit=4,
max_scale=4.0,
use_pruning=False
)
3.1.2. Custum Layer and Block (CascadeConv, ...)
3.1.2.1. Keras
>>> from ddesigner_api.tensorflow import dpi_layers as dlayers
>>> dlayers.CascadeConv2d(
2, 3,
...
transform=4,
max_scale=4.0,
pruning=None,
)
3.1.2.2. PyTorch
>>> from ddesigner_api.pytorch import dpi_nn as dnn
>>> dnn.CascadeConv2d(
16, # in_channels
32, # out_channels
7, # kernel_size
stride=(1,1),
bias=False,
...
transform=4,
max_scale=4.0,
pruning=None,
)
3.2. Blocks
3.2.1. Keras
3.2.1.1. Conv1DBlock
>>> from ddesigner_api.tensorflow import dpi_blocks as db
>>> dtype='mixed_float16'
>>> db.Conv1DBlock(
64, 3, strides=1, padding='SAME', use_bias=False,
activation=tf.keras.layers.ReLU(dtype=dtype),
batchnormalization=tf.keras.layers.BatchNormalization(dtype=dtype),
dtype=dtype,
transform=4, max_scale=4.0,
pruning=0.5
)
3.2.1.2. Conv2DBlock
>>> from ddesigner_api.tensorflow import dpi_blocks as db
>>> dtype='mixed_float16'
>>> db.Conv2DBlock(
64, (3,3), strides=(1,1), padding='SAME', use_bias=False,
activation=tf.keras.layers.ReLU(dtype=dtype),
batchnormalization=tf.keras.layers.BatchNormalization(dtype=dtype),
dtype=dtype,
transform=4, max_scale=4.0,
pruning=0.5
)
3.2.1.3. TConv2DBlock
>>> from ddesigner_api.tensorflow import dpi_blocks as db
>>> dtype='mixed_float16'
>>> db.TConv2DBlock(
64, (3,3), strides=(2,2), padding='SAME', use_bias=False,
activation=tf.keras.layers.ReLU(dtype=dtype),
batchnormalization=tf.keras.layers.BatchNormalization(dtype=dtype),
dtype=dtype,
transform=4, max_scale=4.0,
pruning=0.5
)
3.3. Examples
- An example of comparing and printing results before optimization(XWN) and after XWN for the same input on a supported platform.
3.3.1. Tensorflow
>>> import ddesigner_api.tensorflow.examples.examples_tensorflow as ex
>>> ex.main()
>>> ====== TENSORFLOW Examples======
>>> 1: Fixed Float32 Input Conv2D
>>> q: Quit
>>> Select Case: ...
3.3.2. Keras
>>> import ddesigner_api.tensorflow.examples.examples_keras as ex
>>> ex.main()
>>> ====== KERAS Examples======
>>> 1: Fixed Float32 Input Conv2D
>>> 2: Random Float32 Input Conv2D
>>> 3: Random Float32 Input Conv2DTranspose
>>> 4: Random Float16 Input Conv2D
>>> q: Quit
>>> Select Case: ...
3.3.3. PyTorch
>>> import ddesigner_api.pytorch.examples.examples_pytorch as ex
>>> ex.main()
>>> ====== PYTORCH Examples======
>>> 1: Fixed Float32 Input Conv2D
>>> 2: Random Float32 Input Conv2D
>>> 3: Fixed Float32 Input Conv1D
>>> 4: Fixed Float32 Input Conv1DTranspose
>>> 5: Random Float32 Input CascadeConv2D
>>> 6: Random Float32 Input CascadeConv1D
>>> q: Quit
>>> Select Case: ...
3.3.4. Numpy
>>> import ddesigner_api.numpy.examples.examples_numpy as ex
>>> ex.main()
>>> ====== NUMPY Examples======
>>> 1: XWN Transform
>>> 2: XWN Transform and Pruning
>>> q: Quit
>>> Select Case: ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file DDesignerAPI-0.0.4.4-py3-none-any.whl
.
File metadata
- Download URL: DDesignerAPI-0.0.4.4-py3-none-any.whl
- Upload date:
- Size: 60.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4dc7c33622a2c09c9c0f4410b517f06b6dbf82d11428b78faf61f60446562fb |
|
MD5 | 29da36163b4fea56201ca580973055f2 |
|
BLAKE2b-256 | 984d7cfefa088ec3f646fb484ec8576f682c6239a0a6e1518ba9725b35a493eb |