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

Function run

examples/cnn_ms/train_cnn.py:279–485  ·  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

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

Callers 1

train_cnn.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