Lab 7: Neural Nets

From 6.034 Wiki

(Difference between revisions)
Jump to: navigation, search
(Neural Nets)
(5 Equations)
Line 66: Line 66:
margin_width
margin_width
-
check_gutter_constraint
+
[I'm changing the docstrings for check_gutter_constraint and check_alphas, so I'll add those later. -jmn) #TODO
-
 
+
-
check_alphas
+
=== Classification Accuracy ===
=== Classification Accuracy ===

Revision as of 01:28, 5 November 2015

Contents


This lab is due by TODO at 10:00pm.

To work on this lab, you will need to get the code, much like you did for the first two labs.


Your answers for this lab belong in the main file lab6.py.

Problems

Neural Nets

Helper functions

stairstep: Computes the output of the stairstep function using the given threshold

sigmoid: Computes the output of the sigmoid function using the given steepness and midpoint

accuracy: Computes accuracy using desired_output and actual_output. If the output is binary, the accuracy ranges from -0.5 to 0

Wiring a neural net

TODO (this section will probably be cut, or maybe changed to just specifying number of neurons per layer)

Forward propagation

Given a neural net and dictionary of input values, performs forward propagation with the given threshold function to compute binary output.

This function should not modify the input net and will return a tuple containing:

 1) a dictionary mapping neurons to their immediate outputs
 2) the final binary output (0 or 1)

Backward propagation

update_weights: Performs a single step of back propagation. Computes delta_B values and weight updates for entire neural net, then updates all weights. Uses the sigmoid function to compute output.

Returns a tuple containing:

    (1) the modified neural net, with updated weights
    (2) a dictionary mapping neurons to delta_B values


back_prop: Updates the weights until the accuracy surpasses minimum_accuracy. Uses the sigmoid function to compute output.

Returns a tuple containing:
    (1) the modified neural net, with trained weights
    (2) the number of iterations (that is, the number of weight updates)

Support Vector Machines

TODO describe functions below (basically copy docstrings and reformat)

Vector Math

norm(v): Returns the length of the vector v. Note that v can either be a Point instance or a tuple/list of coordinates.

dot_product(u,v): Computes the dot product of two vectors u, v. Again, each vector can either be a Point instance or tuple/list of coordinates.

5 Equations

  1. todo also include the 5 equations here so students can refer to them

positiveness

classify

margin_width

[I'm changing the docstrings for check_gutter_constraint and check_alphas, so I'll add those later. -jmn) #TODO

Classification Accuracy

count_misclassified_training_points

Survey

Please answer these questions at the bottom of your lab6.py file:

  • NAME: What is your name? (string)
  • COLLABORATORS: Other than 6.034 staff, whom did you work with on this lab? (string, or empty string if you worked alone)
  • HOW_MANY_HOURS_THIS_LAB_TOOK: Approximately how many hours did you spend on this lab? (number or string)
  • WHAT_I_FOUND_INTERESTING: Which parts of this lab, if any, did you find interesting? (string)
  • WHAT_I_FOUND_BORING: Which parts of this lab, if any, did you find boring or tedious? (string)
  • (optional) SUGGESTIONS: What specific changes would you recommend, if any, to improve this lab for future years? (string)


(We'd ask which parts you find confusing, but if you're confused you should really ask a TA.)

When you're done, run the online tester to submit your code.

API

Neural Nets

The file neural_net_api.py defines the Wire and NeuralNet classes, described below.

Wire

TODO

NeuralNet

TODO

Support Vector Machines

The file svm_api.py defines the Point, DecisionBoundary, and SupportVectorMachine classes, as well as some helper functions for vector math, all described below.

Point

TODO

DecisionBoundary

TODO

SupportVectorMachine

TODO

Helper functions for vector math

TODO add docstrings + format

vector_mult

scalar_add

Personal tools