apps/train.py
def build_model(arch=None, hidden_units=None):
    '''build the deep neural network model'''

    if arch is None:
        arch = 'vgg16'
    hidden_units = 4096 if hidden_units is None else int(hidden_units)

    # choosing architecture
    if arch == 'vgg16':
        model = models.vgg16(pretrained=True)
        input_units = 25088
    elif arch == 'alexnet':
        model = models.alexnet(pretrained=True)
        input_units = 9216
    elif arch == 'densenet121':
        model = models.densenet121(pretrained=True)
        input_units = 1024

    # Freeze parameters so we don't backprop through them
    for param in model.parameters():
        param.requires_grad = False

    # creating new classifier
    classifier = nn.Sequential(
        nn.Linear(input_units, int(hidden_units)),
        nn.ReLU(),
        nn.Dropout(.5),
        nn.Linear(hidden_units, 102),
        nn.LogSoftmax(dim=1)
    )

    model.classifier = classifier
    return model
build the deep neural network model
build the deep neural network model
build the deep neural network model
def build_model(arch=None, hidden_units=None):
    if arch is None:
        arch = 'vgg16'
    hidden_units = 4096 if hidden_units is None else int(hidden_units)
    if arch == 'vgg16':
        model = models.vgg16(pretrained=True)
        input_units = 25088
    elif arch == 'alexnet':
        model = models.alexnet(pretrained=True)
        input_units = 9216
    elif arch == 'densenet121':
        model = models.densenet121(pretrained=True)
        input_units = 1024
    for param in model.parameters():
        param.requires_grad = False
    classifier = nn.Sequential(
        nn.Linear(input_units, int(hidden_units)),
        nn.ReLU(),
        nn.Dropout(.5),
        nn.Linear(hidden_units, 102),
        nn.LogSoftmax(dim=1)
    )
    model.classifier = classifier
    return model
def build_model ( arch = None , hidden_units = None ) : if arch is None : arch = 'vgg16' hidden_units = 4096 if hidden_units is None else int ( hidden_units ) if arch == 'vgg16' : model = models . vgg16 ( pretrained = True ) input_units = 25088 elif arch == 'alexnet' : model = models . alexnet ( pretrained = True ) input_units = 9216 elif arch == 'densenet121' : model = models . densenet121 ( pretrained = True ) input_units = 1024 for param in model . parameters ( ) : param . requires_grad = False classifier = nn . Sequential ( nn . Linear ( input_units , int ( hidden_units ) ) , nn . ReLU ( ) , nn . Dropout ( .5 ) , nn . Linear ( hidden_units , 102 ) , nn . LogSoftmax ( dim = 1 ) ) model . classifier = classifier return model
build the deep neural network model
build the deep neural network model
'''build the deep neural network model''' # choosing architecture # Freeze parameters so we don't backprop through them # creating new classifier
arch
hidden_units