https://github.com/lvyufeng/easy_mindspore_bk
https://github.com/lvyufeng/easy_mindspore_bk
deep-learning easy-to-use mindspore
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lvyufeng/easy_mindspore_bk
- Owner: lvyufeng
- License: mit
- Created: 2021-02-04T16:49:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-21T16:37:26.000Z (over 2 years ago)
- Last Synced: 2024-10-28T06:00:08.301Z (7 months ago)
- Topics: deep-learning, easy-to-use, mindspore
- Language: Python
- Homepage:
- Size: 78.1 KB
- Stars: 18
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Easy MindSpore: a MindSpore warapper for easy usage.
## About EasyMS
## How to use
### Install
```bash
python setup.py install
```### A functional usage instead of Cell
```python
def train_one_epoch(net, loss_fn, optimizer, dataset, every_print=1, epoch_num=0):
"""train network in one epoch"""
@ms_function
def train_step(x, y):
logits = net(x)
loss = loss_fn(logits, y)
return loss, logits, xgrad_fn = value_and_grad(train_step, net.trainable_params(), has_aux=True)
steps = 0
for x, y in dataset.create_tuple_iterator():
steps += 1
(loss, _), grads = grad_fn(x, y)
optimizer(grads)
if steps % every_print == 0:
print(f"epoch: {epoch_num}, loss: {loss.asnumpy()}")
```