Skip to content

Instantly share code, notes, and snippets.

View ROZBEH's full-sized avatar
💻
Tinkering

ROZBEH

💻
Tinkering
View GitHub Profile
'''Trains a multi-output deep NN on the MNIST dataset using crossentropy and
policy gradients (REINFORCE).
The goal of this example is twofold:
* Show how to use policy graidents for training
* Show how to use generators with multioutput models
# Policy graidients
This is a Reinforcement Learning technique [1] that trains the model
following the gradient of the logarithm of action taken scaled by the advantage
(reward - baseline) of that action.
# Generators
@bstriner
bstriner / keras_backend_optimizer_example.py
Last active October 13, 2021 01:23
How to use Keras backend and optimizers directly outside of a Keras model
from keras.optimizers import Adam
from keras import backend as K
from keras.datasets import mnist
from keras.utils.np_utils import to_categorical
from keras.metrics import categorical_accuracy
from keras.initializations import glorot_uniform, zero
import numpy as np
# inputs and targets are placeholders
input_dim = 28*28