Distributed Neural Network implementation on COINSTAC.
Project description
coinstac-dinunet
Distributed Neural Network implementation on COINSTAC.
pip install coinstac-dinunet
Install supported pytorch & torchvision binaries in your device/docker ecosystem:
torch==1.5.1+cu92
torchvision==0.6.1+cu92
Highlights:
1. Handles multi-network/complex training schemes.
2. Automatic data splitting/k-fold cross validation.
3. Automatic model checkpointing.
4. GPU enabled local sites.
5. Customizable metrics(w/Auto serialization between nodes) to work with any schemes.
6. We can integrate any custom reduction and learning mechanism by extending coinstac_dinunet.distrib.reducer/learner.
7. Realtime profiling each sites by specifying in compspec file(see dinune_fsv example below for details).
...
Working examples:
Development guide - Add a new NN computation to COINSTAC:
imports
from coinstac_dinunet import COINNDataset, COINNTrainer, COINNLocal
from coinstac_dinunet.metrics import COINNAverages, Prf1a
1. Define Data Loader
class MyDataset(COINNDataset):
def __init__(self, **kw):
super().__init__(**kw)
self.labels = None
def load_index(self, id, file):
data_dir = self.path(id, 'data_dir') # data_dir comes from inputspecs.json
...
self.indices.append([id, file])
def __getitem__(self, ix):
id, file = self.indices[ix]
data_dir = self.path(id, 'data_dir') # data_dir comes from inputspecs.json
label_dir = self.path(id, 'label_dir') # label_dir comes from inputspecs.json
...
# Logic to load, transform single data item.
...
return {'inputs':.., 'labels': ...}
2. Define Trainer
class MyTrainer(COINNTrainer):
def __init__(self, **kw):
super().__init__(**kw)
def _init_nn_model(self):
self.nn['model'] = MYModel(in_size=self.cache['input_size'], out_size=self.cache['num_class'])
def iteration(self, batch):
inputs, labels = batch['inputs'].to(self.device['gpu']).float(), batch['labels'].to(self.device['gpu']).long()
out = F.log_softmax(self.nn['model'](inputs), 1)
loss = F.nll_loss(out, labels)
_, predicted = torch.max(out, 1)
score = self.new_metrics()
score.add(predicted, labels)
val = self.new_averages()
val.add(loss.item(), len(inputs))
return {'out': out, 'loss': loss, 'averages': val,
'metrics': score, 'prediction': predicted}
3. Add entries to:
Note: Computations can only be either CPU or GPU only.
Define custom metrics if needed(Mostly not required)
- Extend coinstac_dinunet.metrics.COINNMetrics
- Example: coinstac_dinunet.metrics.Prf1a for Precision, Recall, F1, and Accuracy
Define custom DataHandle if necessary.
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 Distribution
coinstac-dinunet-2.1.1.tar.gz
(32.4 kB
view details)
File details
Details for the file coinstac-dinunet-2.1.1.tar.gz
.
File metadata
- Download URL: coinstac-dinunet-2.1.1.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19282083020010ce75a0c29291b488f3abe357654e26533522ee760767bd993 |
|
MD5 | 225427fb4199cb0909ca1ee5322f59e0 |
|
BLAKE2b-256 | cf0b8e9716737e037d6a86304a15f584e438112d83f49dc62de69dfb0c823988 |