Skip to content

Instantly share code, notes, and snippets.

@Tathagatd96
Created December 6, 2017 14:14
Show Gist options
  • Save Tathagatd96/0d3082c0c592eb51eb91cdea5d43b9cc to your computer and use it in GitHub Desktop.
Save Tathagatd96/0d3082c0c592eb51eb91cdea5d43b9cc to your computer and use it in GitHub Desktop.
###Training the model
#Run the training function per mini-batches.
n_examples = X_train.shape[0]
n_batches = n_examples / batch_size
epochs=50
for epoch in xrange(epochs):
for batch in xrange(n_batches):
x_batch = X_train[batch*batch_size: (batch+1) * batch_size]
y_batch = y_train[batch*batch_size: (batch+1) * batch_size]
train_fn(x_batch, y_batch) # This is where the model gets updated
###Testing the model
loss, acc = val_fn(X_test, y_test)
test_error = 1 - acc
print('Test error: %f' % test_error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment