Hi, you can start by just looking how "built-in" keras optimizers are implemented:
https://github.com/fchollet/keras/blob/master/keras/optimizers.py
That is pretty easy, you just instantiate your Optimizer and pass it as parameter to model.fit:
opt = MyCustomOptimizer()
model.fit(loss = "foo", optimizer = opt)
And that's it.
Oh my mistake!
You pass the optimizer to model.compile, not model.fit
/usr/local/lib/python3.6/site-packages/keras/engine/training.py in _make_train_function(self) 935 self._collected_trainable_weights, 936 self.constraints, --> 937 self.total_loss) 938 updates = self.updates + training_updates 939 # Gets loss and metrics. Updates weights at each call. TypeError: get_updates() takes 3 positional arguments but 4 were given