/*************************************************** Starter code for CS182 Part2 Assignment 4: Backpropagation Unit.java **************************************************/ import java.util.*; /** * Unit is the basic unit of a neural network. */ public class Unit { // Unit attributes // ** to be filled in ** // The following Unit attributes are suggested starting points // for the assignment. You may wish to modify them as necessary // for your particular implementation. Vector in; // input Units for this Unit Vector out; // output Units for this Unit double[] inWeights; // current (input) weights for this Unit double activation; // this unit's activation level double error; // this unit's error double delta; // this unit's delta double weightChange[]; // weight changes for each weight int index; // index number for this Unit Net net; // network this unit belongs to /** * Constructor for Unit class. * Takes an index number and Net to which Unit belongs. * */ public Unit () { in = new Vector(); out = new Vector(); } public void addIncomingUnit(Unit inUnit) { this.in.add(inUnit); } public void setOutgoingUnit(Unit outUnit) { this.out.add(outUnit); } // Below are some suggested methods that you may wish to complete // and use in your implementation. /** * initalize() * Randomize all incoming weights between the network's * minimum and maximum weights, including bias weights. */ public void initialize() { this.inWeights = new double[in.size()]; for(int i=0; i