Module Expr Str Import alias Import alias identifier ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListComp Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Num comprehension NameStore SubscriptLoad NameLoad Slice Num Assign AttributeStore NameLoad attr ListComp Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Slice Num SubscriptLoad NameLoad Slice Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore Call NameLoad BinOpAdd Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad For NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp SubscriptLoad NameLoad Slice NameLoad BinOpAdd NameLoad NameLoad comprehension NameStore Call NameLoad Num NameLoad NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Print Call AttributeLoad Str attr NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Print Call AttributeLoad Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListComp Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Assign NameStore ListComp Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr For TupleStore NameStore NameStore NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore ListComp BinOpAdd NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad Assign NameStore ListComp BinOpAdd NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr ListComp BinOpSub NameLoad BinOpMult BinOpDiv NameLoad Call NameLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListComp BinOpSub NameLoad BinOpMult BinOpDiv NameLoad Call NameLoad NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListComp Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Assign NameStore ListComp Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr comprehension NameStore AttributeLoad NameLoad attr Assign NameStore NameLoad Assign NameStore ListLoad NameLoad Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpMult Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num NameLoad Call NameLoad SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Num NameLoad Assign SubscriptStore NameLoad Index Num Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad SubscriptLoad NameLoad Index Num attr For NameStore Call NameLoad Num AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad NameLoad Index UnaryOpUSub NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore BinOpMult Call AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index BinOpAdd UnaryOpUSub NameLoad Num attr NameLoad NameLoad Assign SubscriptStore NameLoad Index UnaryOpUSub NameLoad NameLoad Assign SubscriptStore NameLoad Index UnaryOpUSub NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad SubscriptLoad NameLoad Index BinOpSub UnaryOpUSub NameLoad Num attr Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListComp TupleLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension TupleStore NameStore NameStore NameLoad Return Call NameLoad GeneratorExp Call NameLoad CompareEq NameLoad NameLoad comprehension TupleStore NameStore NameStore NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Return BinOpSub NameLoad NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpDiv Num BinOpAdd Num Call AttributeLoad NameLoad attr UnaryOpUSub NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpMult Call NameLoad NameLoad BinOpSub Num Call NameLoad NameLoad decorator_list
N/A N/A 
network.py
~~~~~~~~~~

A module to implement the stochastic gradient descent learning
algorithm for a feedforward neural network.  Gradients are calculated
using backpropagation.  Note that I have focused on making the code
simple, easily readable, and easily modifiable.  It is not optimized,
and omits many desirable features.
 N/A random N/A numpy np Network N/A object N/A __init__ N/A N/A self sizes N/A N/A N/A The list ``sizes`` contains the number of neurons in the
        respective layers of the network.  For example, if the list
        was [2, 3, 1] then it would be a three-layer network, with the
        first layer containing 2 neurons, the second layer 3 neurons,
        and the third layer 1 neuron.  The biases and weights for the
        network are initialized randomly, using a Gaussian
        distribution with mean 0, and variance 1.  Note that the first
        layer is assumed to be an input layer, and by convention we
        won't set any biases for those neurons, since biases are only
        ever used in computing the outputs from later layers. N/A N/A self num_layers N/A len sizes N/A N/A self sizes sizes N/A N/A self biases N/A N/A N/A N/A np random randn y 1 N/A y N/A sizes N/A 1 N/A N/A self weights N/A N/A N/A N/A np random randn y x N/A N/A x y N/A zip N/A sizes N/A -1 N/A sizes N/A 1 N/A feedforward N/A N/A self a N/A N/A N/A Return the output of the network if ``a`` is input. N/A N/A b w N/A zip N/A self biases N/A self weights N/A N/A a N/A sigmoid N/A N/A N/A np dot w a b N/A a N/A SGD N/A N/A self training_data epochs mini_batch_size eta test_data N/A None N/A N/A Train the neural network using mini-batch stochastic
        gradient descent.  The ``training_data`` is a list of tuples
        ``(x, y)`` representing the training inputs and the desired
        outputs.  The other non-optional parameters are
        self-explanatory.  If ``test_data`` is provided then the
        network will be evaluated against the test data after each
        epoch, and partial progress printed out.  This is useful for
        tracking progress, but slows things down substantially. N/A test_data N/A N/A n_test N/A len test_data N/A n N/A len training_data N/A j N/A xrange epochs N/A N/A N/A N/A random shuffle training_data N/A mini_batches N/A N/A training_data N/A k N/A k mini_batch_size N/A k N/A xrange 0 n mini_batch_size N/A mini_batch mini_batches N/A N/A N/A N/A self update_mini_batch mini_batch eta N/A test_data N/A N/A N/A N/A Epoch {0}: {1} / {2} format j N/A N/A self evaluate test_data n_test N/A N/A N/A N/A Epoch {0} complete format j N/A update_mini_batch N/A N/A self mini_batch eta N/A N/A N/A Update the network's weights and biases by applying
        gradient descent using backpropagation to a single mini batch.
        The ``mini_batch`` is a list of tuples ``(x, y)``, and ``eta``
        is the learning rate. N/A nabla_b N/A N/A N/A np zeros N/A b shape N/A b N/A self biases N/A nabla_w N/A N/A N/A np zeros N/A w shape N/A w N/A self weights N/A N/A x y mini_batch N/A N/A N/A delta_nabla_b delta_nabla_w N/A N/A self backprop x y N/A nabla_b N/A N/A nb dnb N/A N/A nb dnb N/A zip nabla_b delta_nabla_b N/A nabla_w N/A N/A nw dnw N/A N/A nw dnw N/A zip nabla_w delta_nabla_w N/A N/A self weights N/A N/A w N/A N/A eta N/A len mini_batch nw N/A N/A w nw N/A zip N/A self weights nabla_w N/A N/A self biases N/A N/A b N/A N/A eta N/A len mini_batch nb N/A N/A b nb N/A zip N/A self biases nabla_b N/A backprop N/A N/A self x y N/A N/A N/A Return a tuple ``(nabla_b, nabla_w)`` representing the
        gradient for the cost function C_x.  ``nabla_b`` and
        ``nabla_w`` are layer-by-layer lists of numpy arrays, similar
        to ``self.biases`` and ``self.weights``. N/A nabla_b N/A N/A N/A np zeros N/A b shape N/A b N/A self biases N/A nabla_w N/A N/A N/A np zeros N/A w shape N/A w N/A self weights N/A activation x N/A activations N/A x N/A zs N/A N/A N/A b w N/A zip N/A self biases N/A self weights N/A N/A z N/A N/A N/A np dot w activation b N/A N/A N/A zs append z N/A activation N/A sigmoid z N/A N/A N/A activations append activation N/A delta N/A N/A N/A self cost_derivative N/A activations N/A -1 y N/A sigmoid_prime N/A zs N/A -1 N/A N/A nabla_b N/A -1 delta N/A N/A nabla_w N/A -1 N/A N/A np dot delta N/A N/A N/A activations N/A -2 transpose N/A l N/A xrange 2 N/A self num_layers N/A N/A z N/A zs N/A N/A l N/A sp N/A sigmoid_prime z N/A delta N/A N/A N/A np dot N/A N/A N/A N/A self weights N/A N/A N/A l 1 transpose delta sp N/A N/A nabla_b N/A N/A l delta N/A N/A nabla_w N/A N/A l N/A N/A np dot delta N/A N/A N/A activations N/A N/A N/A l 1 transpose N/A N/A nabla_b nabla_w N/A evaluate N/A N/A self test_data N/A N/A N/A Return the number of test inputs for which the neural
        network outputs the correct result. Note that the neural
        network's output is assumed to be the index of whichever
        neuron in the final layer has the highest activation. N/A test_results N/A N/A N/A N/A np argmax N/A N/A self feedforward x y N/A N/A x y test_data N/A N/A sum N/A N/A int N/A x y N/A N/A x y test_results N/A cost_derivative N/A N/A self output_activations y N/A N/A N/A Return the vector of partial derivatives \partial C_x /
        \partial a for the output activations. N/A N/A output_activations y N/A N/A sigmoid N/A N/A z N/A N/A N/A The sigmoid function. N/A N/A 1.0 N/A 1.0 N/A N/A np exp N/A z N/A sigmoid_prime N/A N/A z N/A N/A N/A Derivative of the sigmoid function. N/A N/A N/A sigmoid z N/A 1 N/A sigmoid z N/A