# numpynet
Convolutional Neural Network written from scratch using numpy with API similar to tensorflow. Library was compared with tensorflow versions of network (`demo` directory) and achieved very close results.
## Implemented Elements
### Layers
- `InputLayer`
- `DenseLayer`
- `BiasLayer`
- `ActivationLayer (relu, leaky reLu, sigmoid, tanh, sin)`
- `DropoutLayer`
- `FlattenLayer`
- `Conv2DLayer (with bias & stride)`
- `Pool2DLayer (max, min)`
- `Padding2DLayer`
- `Crop2DLayer`
- `SoftmaxLayer`
### Losses
- `MSE`
- `CCE`
### Initializers
- `ConstantInitializer`
- `RandomNormalInitializer`
- `RandomUniformInitializer`
- `GlorotUniformInitialization`
### Metrics
- `CategoricalAccuracy`
### Callbacks
- `ModelCheckpoint`
- `EarlyStopping`
## Usage Example
### Definition
```
layers = [
numpynet.layers.InputLayer((28, 28, 1)),
numpynet.layers.Conv2DLayer(32, kernel_size=3, stride=1),
numpynet.layers.ActivationLayer('relu'),
numpynet.layers.FlattenLayer(),
numpynet.layers.DenseLayer(128),
numpynet.layers.BiasLayer(),
numpynet.layers.ActivationLayer('relu'),
numpynet.layers.DropoutLayer(0.5),
numpynet.layers.DenseLayer(10),
numpynet.layers.BiasLayer(),
numpynet.layers.SoftmaxLayer(),
]
model = numpynet.network.Sequential(layers)
```
### Compilation
```
model.compile(
loss='cce',
metrics=['categorical_accuracy']
)
```
### Fitting
```
checkpoint_callback = numpynet.callbacks.ModelCheckpoint('checkpoint.dat')
history = model.fit(
train_x,
train_y,
validation_data=(test_x, test_y),
learning_rate=0.001,
epochs=10,
callbacks=[checkpoint_callback],
)
```
### Predicting
```
predictions = model.predict(test_x)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/klima7/CNN-From-Scratch",
"name": "numpynet",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "neural,network,numpy,simple,convolution,dense",
"author": "\u0141ukasz Klimkiewicz",
"author_email": "pypi@mail.ukasz.com",
"download_url": "",
"platform": null,
"description": "# numpynet\r\nConvolutional Neural Network written from scratch using numpy with API similar to tensorflow. Library was compared with tensorflow versions of network (`demo` directory) and achieved very close results.\r\n\r\n## Implemented Elements\r\n\r\n### Layers\r\n- `InputLayer`\r\n- `DenseLayer`\r\n- `BiasLayer`\r\n- `ActivationLayer (relu, leaky reLu, sigmoid, tanh, sin)`\r\n- `DropoutLayer`\r\n- `FlattenLayer`\r\n- `Conv2DLayer (with bias & stride)`\r\n- `Pool2DLayer (max, min)`\r\n- `Padding2DLayer`\r\n- `Crop2DLayer`\r\n- `SoftmaxLayer`\r\n\r\n### Losses\r\n- `MSE`\r\n- `CCE`\r\n\r\n### Initializers\r\n- `ConstantInitializer`\r\n- `RandomNormalInitializer`\r\n- `RandomUniformInitializer`\r\n- `GlorotUniformInitialization`\r\n\r\n### Metrics\r\n- `CategoricalAccuracy`\r\n\r\n### Callbacks\r\n- `ModelCheckpoint`\r\n- `EarlyStopping`\r\n\r\n## Usage Example\r\n\r\n### Definition\r\n```\r\nlayers = [\r\n numpynet.layers.InputLayer((28, 28, 1)),\r\n numpynet.layers.Conv2DLayer(32, kernel_size=3, stride=1),\r\n numpynet.layers.ActivationLayer('relu'),\r\n numpynet.layers.FlattenLayer(),\r\n numpynet.layers.DenseLayer(128),\r\n numpynet.layers.BiasLayer(),\r\n numpynet.layers.ActivationLayer('relu'),\r\n numpynet.layers.DropoutLayer(0.5),\r\n numpynet.layers.DenseLayer(10),\r\n numpynet.layers.BiasLayer(),\r\n numpynet.layers.SoftmaxLayer(),\r\n]\r\n\r\nmodel = numpynet.network.Sequential(layers)\r\n```\r\n\r\n### Compilation\r\n```\r\nmodel.compile(\r\n loss='cce',\r\n metrics=['categorical_accuracy']\r\n)\r\n```\r\n\r\n### Fitting\r\n```\r\ncheckpoint_callback = numpynet.callbacks.ModelCheckpoint('checkpoint.dat')\r\n\r\nhistory = model.fit(\r\n train_x,\r\n train_y,\r\n validation_data=(test_x, test_y),\r\n learning_rate=0.001,\r\n epochs=10,\r\n callbacks=[checkpoint_callback],\r\n)\r\n```\r\n\r\n### Predicting\r\n```\r\npredictions = model.predict(test_x)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple neural network implementation with numpy",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/klima7/CNN-From-Scratch"
},
"split_keywords": [
"neural",
"network",
"numpy",
"simple",
"convolution",
"dense"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cbacdf4552feb943c8508eeb2af1463e51e2cdc5703bf13463c10d3250bcc27c",
"md5": "666ba8fa30c7fad5d10f7a3275e64632",
"sha256": "b30ea985b5efb1a113ccecc1640f3d7e105859ae70274ca46c9ff8957beb53a0"
},
"downloads": -1,
"filename": "numpynet-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "666ba8fa30c7fad5d10f7a3275e64632",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19057,
"upload_time": "2024-03-17T23:03:26",
"upload_time_iso_8601": "2024-03-17T23:03:26.376877Z",
"url": "https://files.pythonhosted.org/packages/cb/ac/df4552feb943c8508eeb2af1463e51e2cdc5703bf13463c10d3250bcc27c/numpynet-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-17 23:03:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "klima7",
"github_project": "CNN-From-Scratch",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "numpynet"
}