forked from mnielsen/neural-networks-and-deep-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracking gradients in different layers, and serializing some MNIST im…
…ages to JSON
- Loading branch information
Showing
11 changed files
with
156 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[[-0.00015957744575933252, -7.109660645293893e-06, 0.00029705824697869363, -0.005433034945183055, -0.000601732153598837, -0.00031497136113071197], [-0.004743788813673901, -0.003335113231382309, -0.006826947354624844, 0.001668145239275299, -0.013916515462361398, 0.002312540509777085], [0.05364605271597593, -0.0057698230441689275, -0.010571727068813678, 0.07860259192197483, 0.014443898612513025, -0.019157824473129328]] | ||
[[-0.003970677333144113, -0.0031684316985881185, 0.008103235909196014, 0.012598010584130365, -0.026465907331998335, 0.0017583319323150341], [0.04152906589960523, 0.044025552524932406, -0.009669682279354514, 0.046736871369353235, 0.03877302528270452, 0.012336459551975156]] |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
serialize_images_to_json | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Utility to serialize parts of the training and validation data to JSON, | ||
for use with Javascript. """ | ||
|
||
#### Libraries | ||
# Standard library | ||
import json | ||
import sys | ||
|
||
# My library | ||
sys.path.append('../code/') | ||
import mnist_loader | ||
|
||
# Third-party libraries | ||
import numpy as np | ||
|
||
|
||
# Number of training and validation data images to serialize | ||
NTD = 1000 | ||
NVD = 100 | ||
|
||
training_data, validation_data, test_data = mnist_loader.load_data_wrapper() | ||
|
||
def make_data_integer(td): | ||
# This will be slow, due to the loop. It'd be better if numpy did | ||
# this directly. But numpy.rint followed by tolist() doesn't | ||
# convert to a standard Python int. | ||
return [int(x) for x in (td*256).reshape(784).tolist()] | ||
|
||
data = {"training": [ | ||
{"x": [x[0] for x in training_data[j][0].tolist()], | ||
"y": [y[0] for y in training_data[j][1].tolist()]} | ||
for j in xrange(NTD)], | ||
"validation": [ | ||
{"x": [x[0] for x in validation_data[j][0].tolist()], | ||
"y": validation_data[j][1]} | ||
for j in xrange(NVD)]} | ||
|
||
f = open("data_1000.json", "w") | ||
json.dump(data, f) | ||
f.close() | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.