How can I find the equivalent 'batch_size' used in Keras from this Pytorch code?
I am using Pytorch code from github

I am trying to port this over to Keras. 
In particular, Keras uses model.fit for training the Neural net and has a batch_size parameter. I am trying to set this but cannot determine it in the Pytorch script linked above. 

In the script, there is a function called sliding_window in box 4 where there is a parameter called step. I am not sure if this is the equivalent setting of batch_size.

Also, I am looking into how to set the learning rate scheduler from the box 11 in the Pytorch code:

base_lr = 0.01
params_dict = dict(net.named_parameters())
params = []
for key, value in params_dict.items():
    if '_D' in key:
        # Decoder weights are trained at the nominal learning rate
        params += [{'params':[value],'lr': base_lr}]
    else:
        # Encoder weights are trained at lr / 2 (we have VGG-16 weights as initialization)
        params += [{'params':[value],'lr': base_lr / 2}]

optimizer = optim.SGD(net.parameters(), lr=base_lr, momentum=0.9, weight_decay=0.0005)
# We define the scheduler
scheduler = optim.lr_scheduler.MultiStepLR(optimizer, [25, 35, 45], gamma=0.1)


I have always used the default learning rate from Keras. Any insight on how to go about converting this scheduler into Keras code  would also be appreciated.

Below find an example on how to write a Learning Rate scheduler in Keras:

from keras.callbacks import Callback
from keras import backed as K

class LRSchedule(Callback):
    def __init__(self, schedule):
        super(LRSchedule, self).__init__()
        self.schedule = schedule

    def on_train_begin(self, logs = {}):
        self.epoch_counter = 0
        self.schedule_index = 0

    def on_epoch_end(self, epoch, logs = {}):
        self.epoch_counter += 1

        if len(self.schedule)  &gt; self.schedule_index + 1:
            next_epoch = self.schedule[self.schedule_index + 1]
            if self.epoch_counter == next_epoch:
                K.set_value(self.model.optimizer.lr, self.model.optimizer.lr / 2.0)
                self.schedule_index += 1


In your code, you will call the callback in this way:

lr_scheduler = LRSchedule([25, 35, 45])
model.fit_generator(..., callbacks = [lr_scheduler])


Notice that this scheduler, when an epoch is reached, sets the learning to a lower value dividing by 2.  Modifying it to more fancy schedule policies is trivial.
