trainTargetsSymbols, trainTargetClasses, testData, testDataSymbols, testTargets, testTargetsSymbols, validationData, validationDataSymbols, validationTargets, validationTargetsSymbols, validationTargetClasses ] = data.loadDataSet() # Construct Graph x = tf.placeholder(tf.float32, [None, 20]) [weights, biases, y] = nn.constructNN(x, 20, 20, [256, 256]) y_ = tf.placeholder(tf.float32, [None, 20]) # Session Setup loss = tf.reduce_mean(tf.reduce_sum(tf.square(y_ - y), reduction_indices = [1])) train_step = tf.train.GradientDescentOptimizer(1.0).minimize(loss) sess = tf.Session() init = tf.initialize_all_variables() sess.run(init) # Train NN num_epochs = 5000 [ opt_weights,
for index, item in enumerate(trainTargets): trainTargetsCombined.append( np.concatenate((item, trainTargetsSymbols[index]), axis=0)) for index, item in enumerate(testData): testDataCombined.append( np.concatenate((item, testDataSymbols[index]), axis=0)) for index, item in enumerate(validationData): validationDataCombined.append( np.concatenate((item, validationDataSymbols[index]), axis=0)) for index, item in enumerate(validationTargets): validationTargetsCombined.append( np.concatenate((item, validationTargetsSymbols[index]), axis=0)) # Construct Graph x = tf.placeholder(tf.float32, [None, 1588]) [weights, biases, y] = nn.constructNN(x, 1588, 1588, [100, 100, 100]) y_ = tf.placeholder(tf.float32, [None, 1588]) # Session Setup loss = tf.reduce_mean(tf.reduce_sum(tf.square(y_ - y), reduction_indices=[1])) train_step = tf.train.AdamOptimizer(0.001).minimize(loss) sess = tf.Session() init = tf.initialize_all_variables() sess.run(init) # Train NN num_epochs = 3000 [ opt_weights, opt_biases, final_weights, final_biases, min_training_loss,
import sys, datetime sys.dont_write_bytecode = True import utils, data, nn # Load Datasets trainData = [] trainTargets = [] for a in range(6, 10): for b in range(6, 10): trainData.append(utils.one_hot(a) + utils.one_hot(b)) trainTargets.append(utils.one_hot((a + b) // 10) + utils.one_hot((a + b) % 10)) # Construct Graph x = tf.placeholder(tf.float32, [None, 20]) [weights, biases, y] = nn.constructNN(x, 20, 20, [100, 100]) y_ = tf.placeholder(tf.float32, [None, 20]) # Session Setup loss = tf.reduce_mean(tf.reduce_sum(tf.square(y_ - y), reduction_indices = [1])) train_step = tf.train.AdamOptimizer(0.01).minimize(loss) sess = tf.Session() init = tf.initialize_all_variables() sess.run(init) # Train NN num_epochs = 100000 [ opt_weights,