MCPcopy Create free account
hub / github.com/apache/singa / run

Function run

examples/cnn_ms/train_ms_model.py:272–483  ·  view source on GitHub ↗
(global_rank,
        world_size,
        local_rank,
        max_epoch,
        batch_size,
        model,
        data,
        mssgd,
        graph,
        verbosity,
        dist_option='plain',
        spars=None,
        precision='float32')

Source from the content-addressed store, hash-verified

270
271
272def run(global_rank,
273 world_size,
274 local_rank,
275 max_epoch,
276 batch_size,
277 model,
278 data,
279 mssgd,
280 graph,
281 verbosity,
282 dist_option='plain',
283 spars=None,
284 precision='float32'):
285 # dev = device.create_cuda_gpu_on(local_rank) # need to change to CPU device for CPU-only machines
286 dev = device.get_default_device()
287 dev.SetRandSeed(0)
288 np.random.seed(0)
289
290 if data == 'cifar10':
291 from data import cifar10
292 train_x, train_y, val_x, val_y = cifar10.load()
293 elif data == 'cifar100':
294 from data import cifar100
295 train_x, train_y, val_x, val_y = cifar100.load()
296 elif data == 'mnist':
297 from data import mnist
298 train_x, train_y, val_x, val_y = mnist.load()
299
300
301 num_channels = train_x.shape[1]
302 image_size = train_x.shape[2]
303 data_size = np.prod(train_x.shape[1:train_x.ndim]).item()
304 num_classes = (np.max(train_y) + 1).item()
305
306 if model == 'resnet':
307 from model import resnet
308 model = resnet.resnet50(num_channels=num_channels,
309 num_classes=num_classes)
310 elif model == 'xceptionnet':
311 from model import xceptionnet
312 model = xceptionnet.create_model(num_channels=num_channels,
313 num_classes=num_classes)
314 elif model == 'cnn':
315 from model import cnn
316 model = cnn.create_model(num_channels=num_channels,
317 num_classes=num_classes)
318 elif model == 'alexnet':
319 from model import alexnet
320 model = alexnet.create_model(num_channels=num_channels,
321 num_classes=num_classes)
322 elif model == 'mlp':
323 import os, sys, inspect
324 current = os.path.dirname(
325 os.path.abspath(inspect.getfile(inspect.currentframe())))
326 parent = os.path.dirname(current)
327 sys.path.insert(0, parent)
328 from mlp import model
329 model = model.create_model(data_size=data_size,

Callers 1

train_ms_model.pyFile · 0.70

Calls 15

copy_from_numpyMethod · 0.95
TensorMethod · 0.80
SetVerbosityMethod · 0.80
partitionFunction · 0.70
augmentationFunction · 0.70
resize_datasetFunction · 0.70
accuracyFunction · 0.70
reduce_variableFunction · 0.70
SetRandSeedMethod · 0.45
loadMethod · 0.45
reshapeMethod · 0.45
set_optimizerMethod · 0.45

Tested by

no test coverage detected