# pkbar
 [](https://badge.fury.io/py/pkbar) [](https://pypistats.org/packages/pkbar)
Keras style progressbar for pytorch (PK Bar)
### 1. Show
- `pkbar.Pbar` (progress bar)
```
loading and processing dataset
10/10 [==============================] - 1.0s
```
- `pkbar.Kbar` (keras bar)
```
Epoch: 1/3
100/100 [========] - 10s 102ms/step - loss: 3.7782 - rmse: 1.1650 - val_loss: 0.1823 - val_rmse: 0.4269
Epoch: 2/3
100/100 [========] - 10s 101ms/step - loss: 0.1819 - rmse: 0.4265 - val_loss: 0.1816 - val_rmse: 0.4261
Epoch: 3/3
100/100 [========] - 10s 101ms/step - loss: 0.1813 - rmse: 0.4258 - val_loss: 0.1810 - val_rmse: 0.4254
```
### 2. Install
```
pip install pkbar
```
### 3. Usage
- `pkbar.Pbar` (progress bar)
```python
import pkbar
import time
pbar = pkbar.Pbar(name='loading and processing dataset', target=10)
for i in range(10):
time.sleep(0.1)
pbar.update(i)
```
```
loading and processing dataset
10/10 [==============================] - 1.0s
```
- `pkbar.Kbar` (keras bar) [for a concreate example](https://github.com/yueyericardo/pkbar/blob/master/tests/test.py#L16)
```python
import pkbar
import torch
# training loop
train_per_epoch = num_of_batches_per_epoch
for epoch in range(num_epochs):
################################### Initialization ########################################
kbar = pkbar.Kbar(target=train_per_epoch, epoch=epoch, num_epochs=num_epochs, width=8, always_stateful=False)
# By default, all metrics are averaged over time. If you don't want this behavior, you could either:
# 1. Set always_stateful to True, or
# 2. Set stateful_metrics=["loss", "rmse", "val_loss", "val_rmse"], Metrics in this list will be displayed as-is.
# All others will be averaged by the progbar before display.
###########################################################################################
# training
for i in range(train_per_epoch):
outputs = model(inputs)
train_loss = criterion(outputs, targets)
train_rmse = torch.sqrt(train_loss)
optimizer.zero_grad()
train_loss.backward()
optimizer.step()
############################# Update after each batch ##################################
kbar.update(i, values=[("loss", train_loss), ("rmse", train_rmse)])
########################################################################################
# validation
outputs = model(inputs)
val_loss = criterion(outputs, targets)
val_rmse = torch.sqrt(val_loss)
################################ Add validation metrics ###################################
kbar.add(1, values=[("val_loss", val_loss), ("val_rmse", val_rmse)])
###########################################################################################
```
```
Epoch: 1/3
100/100 [========] - 10s 102ms/step - loss: 3.7782 - rmse: 1.1650 - val_loss: 0.1823 - val_rmse: 0.4269
Epoch: 2/3
100/100 [========] - 10s 101ms/step - loss: 0.1819 - rmse: 0.4265 - val_loss: 0.1816 - val_rmse: 0.4261
Epoch: 3/3
100/100 [========] - 10s 101ms/step - loss: 0.1813 - rmse: 0.4258 - val_loss: 0.1810 - val_rmse: 0.4254
```
### 4. Acknowledge
Keras progbar's code from [`tf.keras.utils.Progbar`](https://github.com/tensorflow/tensorflow/blob/r1.14/tensorflow/python/keras/utils/generic_utils.py#L313)
Raw data
{
"_id": null,
"home_page": "https://github.com/yueyericardo/pkbar",
"name": "pkbar",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Richard Xue",
"author_email": "yueyericardo@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/12/4d/c4210a0743ef62ddfa96b3b501c71a214718189f65df8a22f1eb37f256e3/pkbar-0.5.tar.gz",
"platform": "",
"description": "# pkbar\n [](https://badge.fury.io/py/pkbar) [](https://pypistats.org/packages/pkbar)\n\nKeras style progressbar for pytorch (PK Bar)\n\n### 1. Show\n- `pkbar.Pbar` (progress bar)\n```\nloading and processing dataset\n10/10 [==============================] - 1.0s\n```\n\n- `pkbar.Kbar` (keras bar)\n```\nEpoch: 1/3\n100/100 [========] - 10s 102ms/step - loss: 3.7782 - rmse: 1.1650 - val_loss: 0.1823 - val_rmse: 0.4269\nEpoch: 2/3\n100/100 [========] - 10s 101ms/step - loss: 0.1819 - rmse: 0.4265 - val_loss: 0.1816 - val_rmse: 0.4261\nEpoch: 3/3\n100/100 [========] - 10s 101ms/step - loss: 0.1813 - rmse: 0.4258 - val_loss: 0.1810 - val_rmse: 0.4254\n```\n\n### 2. Install \n```\npip install pkbar\n```\n\n### 3. Usage\n\n- `pkbar.Pbar` (progress bar)\n```python\nimport pkbar\nimport time\n\npbar = pkbar.Pbar(name='loading and processing dataset', target=10)\n\nfor i in range(10):\n time.sleep(0.1)\n pbar.update(i)\n```\n```\nloading and processing dataset\n10/10 [==============================] - 1.0s\n```\n\n- `pkbar.Kbar` (keras bar) [for a concreate example](https://github.com/yueyericardo/pkbar/blob/master/tests/test.py#L16)\n```python\nimport pkbar\nimport torch\n\n# training loop\ntrain_per_epoch = num_of_batches_per_epoch\n\nfor epoch in range(num_epochs):\n ################################### Initialization ########################################\n kbar = pkbar.Kbar(target=train_per_epoch, epoch=epoch, num_epochs=num_epochs, width=8, always_stateful=False)\n # By default, all metrics are averaged over time. If you don't want this behavior, you could either:\n # 1. Set always_stateful to True, or\n # 2. Set stateful_metrics=[\"loss\", \"rmse\", \"val_loss\", \"val_rmse\"], Metrics in this list will be displayed as-is.\n # All others will be averaged by the progbar before display.\n ###########################################################################################\n\n # training\n for i in range(train_per_epoch):\n outputs = model(inputs)\n train_loss = criterion(outputs, targets)\n train_rmse = torch.sqrt(train_loss)\n optimizer.zero_grad()\n train_loss.backward()\n optimizer.step()\n\n ############################# Update after each batch ##################################\n kbar.update(i, values=[(\"loss\", train_loss), (\"rmse\", train_rmse)])\n ########################################################################################\n\n # validation\n outputs = model(inputs)\n val_loss = criterion(outputs, targets)\n val_rmse = torch.sqrt(val_loss)\n\n ################################ Add validation metrics ###################################\n kbar.add(1, values=[(\"val_loss\", val_loss), (\"val_rmse\", val_rmse)])\n ###########################################################################################\n```\n```\nEpoch: 1/3\n100/100 [========] - 10s 102ms/step - loss: 3.7782 - rmse: 1.1650 - val_loss: 0.1823 - val_rmse: 0.4269\nEpoch: 2/3\n100/100 [========] - 10s 101ms/step - loss: 0.1819 - rmse: 0.4265 - val_loss: 0.1816 - val_rmse: 0.4261\nEpoch: 3/3\n100/100 [========] - 10s 101ms/step - loss: 0.1813 - rmse: 0.4258 - val_loss: 0.1810 - val_rmse: 0.4254\n```\n\n### 4. Acknowledge\nKeras progbar's code from [`tf.keras.utils.Progbar`](https://github.com/tensorflow/tensorflow/blob/r1.14/tensorflow/python/keras/utils/generic_utils.py#L313)\n\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Keras Progress Bar for PyTorch",
"version": "0.5",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "00d79b825465b2e1e79b3770f4061d57",
"sha256": "23be653811ffc15f1eec596eaa03fe9e639fd2f8757e88f25627d5123b28f714"
},
"downloads": -1,
"filename": "pkbar-0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "00d79b825465b2e1e79b3770f4061d57",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9179,
"upload_time": "2020-09-06T20:15:33",
"upload_time_iso_8601": "2020-09-06T20:15:33.809083Z",
"url": "https://files.pythonhosted.org/packages/95/8f/28e0a21b27f836a8903315050db17dd68e55bf477b6fde52d1c68da3c8a6/pkbar-0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "3cb919745143b5398066d1be875afcdb",
"sha256": "3a6c389688cfa70c84433171ece71098c7f7181de3ba8375019de5713501ef15"
},
"downloads": -1,
"filename": "pkbar-0.5.tar.gz",
"has_sig": false,
"md5_digest": "3cb919745143b5398066d1be875afcdb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10501,
"upload_time": "2020-09-06T20:15:35",
"upload_time_iso_8601": "2020-09-06T20:15:35.274263Z",
"url": "https://files.pythonhosted.org/packages/12/4d/c4210a0743ef62ddfa96b3b501c71a214718189f65df8a22f1eb37f256e3/pkbar-0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-09-06 20:15:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "yueyericardo",
"github_project": "pkbar",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pkbar"
}