pytorch_script_mode_local_model_inference/pytorch_script_mode_local_model_inference.py [25:47]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if os.path.isfile('./data/cifar-10-batches-py/batches.meta') and \
            os.path.isfile('./data/cifar-10-python.tar.gz') :
        print('Training and evaluation datasets exist')
        test_loader = get_test_data_loader(False)
    else:
        print('Downloading training and evaluation dataset')
        test_loader = get_test_data_loader(True)
    return test_loader


def do_inference_on_local_endpoint(predictor, testloader):
    print('Starting Inference on local mode endpoint')
    dataiter = iter(testloader)
    images, labels = dataiter.next()

    outputs = predictor.predict(images.numpy())

    _, predicted = torch.max(torch.from_numpy(np.array(outputs)), 1)

    print('Predicted: ', ' '.join('%4s' % classes[predicted[j]]
                                  for j in range(4)))

def main():
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



pytorch_script_mode_local_training_and_serving/pytorch_script_mode_local_training_and_serving.py [23:45]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    if os.path.isfile('./data/cifar-10-batches-py/batches.meta') and \
            os.path.isfile('./data/cifar-10-python.tar.gz') :
        print('Training and evaluation datasets exist')
        test_loader = get_test_data_loader(False)
    else:
        print('Downloading training and evaluation dataset')
        test_loader = get_test_data_loader(True)
    return test_loader


def do_inference_on_local_endpoint(predictor, testloader):
    print('Starting Inference on local mode endpoint')
    dataiter = iter(testloader)
    images, labels = dataiter.next()

    outputs = predictor.predict(images.numpy())

    _, predicted = torch.max(torch.from_numpy(np.array(outputs)), 1)

    print('Predicted: ', ' '.join('%4s' % classes[predicted[j]]
                                  for j in range(4)))

def main():
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



