def create_shortened_model(model, layer_depth):
    if (layer_depth < 0):
        println('layer depth must be positive!')
        sys.exit()
    if (layer_depth > len(model.layers)):
        println('layer depth too large!')
        sys.exit()
    wgts = model.layers[layer_depth].get_weights()
    nthLayerNeurons = model.layers[layer_depth].output_shape[1]
    for i in range((len(model.layers) - layer_depth)):
        model.pop()
    model.summary
    model.add(layers.Dense(nthLayerNeurons, activation=None))
    model.layers[layer_depth].set_weights(wgts)
    return Model(inputs=model.input, outputs=model.layers[layer_depth].output)
def create_shortened_model(model, layer_depth):
    if (layer_depth < 0):
        println('layer depth must be positive!')
        sys.exit()
    if (layer_depth > len(model.layers)):
        println('layer depth too large!')
        sys.exit()
    wgts = model.layers[layer_depth].get_weights()
    nthLayerNeurons = model.layers[layer_depth].output_shape[1]
    for i in range((len(model.layers) - layer_depth)):
        model.pop()
    model.summary
    model.add(layers.Dense(nthLayerNeurons, activation=None))
    model.layers[layer_depth].set_weights(wgts)
    return Model(inputs=model.input, outputs=model.layers[layer_depth].output)