def step_decay(epoch_ix, lr, step_size=10, decay_factor=0.5):
    """
    Defines 'step_decay'-type learning rate schedule, to be used in 
    keras.Callbacks.LearningRateScheduler.
    Input
        epoch_ix: index of epoch
        lr: current learning rate
        step_size: positive interger, number of episodes after which learning rate will adapt
        decay_factor: factor by which lr will be multiplied
    Returns
        learning rate as a function of lr and epoch_ix
    """
    if ((epoch_ix > 0) and ((epoch_ix % step_size) == 0)):
        lr = lr * decay_factor
    return lr