def test_decode(self): eq = Equilateral(3, -1, 1) d0 = [0.866, 0.5] d1 = [-0.866, 0.5] d2 = [0, -1] self.assertEqual(2, eq.decode(d0)) self.assertEqual(2, eq.decode(d1)) self.assertEqual(0, eq.decode(d2))
# Initial state is current long term memory. x0 = list(network.long_term_memory) # Train the network. res = minimize(score_funct, x0, method='nelder-mead', tol=0.0001, options={ 'disp': True, 'maxiter': 5000 }) # Create an equilateral table for 3 classes (species of iris) and between the range 0 to 1. This is used # to decide the two output nodes into a species number. eq = Equilateral(3, 0, 1) # Display the final validation. We show all of the iris data as well as the predicted species. for i in xrange(0, len(training_input)): input_data = training_input[i] # Compute the output from the RBF network output_data = network.compute_regression(input_data) ideal_data = training_ideal[i] # Decode the two output neurons into a class number. class_id = eq.decode(output_data) print( str(input_data) + " -> " + inv_classes[class_id] + ", Ideal: " + ideal_species[i])
actual_output = [] for input_data in training_input: output_data = network.compute_regression(input_data) actual_output.append(output_data) result = ErrorCalculation.mse(np.array(actual_output), training_ideal) if result < best_score: best_score = result print("Score: " + str(result)) return result # Initial state is current long term memory. x0 = list(network.long_term_memory) # Train the network. res = minimize(score_funct, x0, method='nelder-mead', tol=0.0001, options={'disp': True, 'maxiter': 5000}) # Create an equilateral table for 3 classes (species of iris) and between the range 0 to 1. This is used # to decide the two output nodes into a species number. eq = Equilateral(3, 0, 1) # Display the final validation. We show all of the iris data as well as the predicted species. for i in range(0, len(training_input)): input_data = training_input[i] # Compute the output from the RBF network output_data = network.compute_regression(input_data) ideal_data = training_ideal[i] # Decode the two output neurons into a class number. class_id = eq.decode(output_data) print(str(input_data) + " -> " + inv_classes[class_id] + ", Ideal: " + ideal_species[i])