import tensorflow as tf from Trainer import Trainer, parse_args import os data_path, epochs = parse_args() sess = tf.InteractiveSession(config=tf.ConfigProto()) def weight_variable(shape): initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial) def bias_variable(shape): initial = tf.constant(0.1, shape=shape) return tf.Variable(initial) x = tf.placeholder(tf.float32, shape=[None, 240, 320, 3]) y_ = tf.placeholder(tf.float32, shape=[None, 3]) x_shaped = tf.reshape(x, [-1, 240 * 320 * 3]) W = tf.Variable(tf.zeros([240 * 320 * 3, 3])) b = tf.Variable(tf.zeros([3])) y = tf.nn.softmax(tf.matmul(x_shaped, W) + b) cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1])) train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy) correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) model_file = os.path.dirname(os.path.realpath(__file__)) + '/' + os.path.basename(__file__)
import tensorflow as tf from Trainer import Trainer, parse_args import os from model import * args = parse_args() data_path = args["datapath"] epochs = args["epochs"] s3_bucket = args['s3_bucket'] show_speed = args['show_speed'] s3_sync = args['s3_sync'] sess = tf.InteractiveSession(config=tf.ConfigProto()) x = tf.placeholder(tf.float32, shape=[None, 240, 320, 3], name='x') y_ = tf.placeholder(tf.float32, shape=[None, 3], name='y_') W_conv1 = weight_variable('layer1', [6, 6, 3, 24]) b_conv1 = bias_variable('layer1', [24]) h_conv1 = tf.nn.relu(conv2d(x, W_conv1) + b_conv1) h_pool1 = max_pool_2x2(h_conv1) W_conv2 = weight_variable('layer2', [6, 6, 24, 24]) b_conv2 = bias_variable('layer2', [24]) h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2) W_conv3 = weight_variable('layer3', [6, 6, 24, 36]) b_conv3 = bias_variable('layer3', [36]) h_conv3 = tf.nn.relu(conv2d(h_conv2, W_conv3) + b_conv3) h_pool3 = max_pool_2x2(h_conv3)
import tensorflow as tf from Trainer import Trainer, parse_args import os from model import * args = parse_args() data_path = args["datapath"] epochs = args["epochs"] s3_bucket = args['s3_bucket'] show_speed = args['show_speed'] s3_sync = args['s3_sync'] sess = tf.InteractiveSession(config=tf.ConfigProto()) x = tf.placeholder(tf.float32, shape=[None, 240, 320, 3], name='x') y_ = tf.placeholder(tf.float32, shape=[None, 3], name='y_') W_conv1 = weight_variable('layer1',[6, 6, 3, 32]) b_conv1 = bias_variable('layer1',[32]) h_conv1 = tf.nn.relu(conv2d(x, W_conv1) + b_conv1) h_pool1 = max_pool_2x2(h_conv1) W_fc1 = weight_variable('layer2',[120 * 160 * 32, 512]) b_fc1 = bias_variable('layer2',[512]) h_pool1_flat = tf.reshape(h_pool1, [-1, 120 * 160 * 32]) h_fc1 = tf.nn.relu(tf.matmul(h_pool1_flat, W_fc1) + b_fc1) dropout_keep_prob = tf.placeholder(tf.float32) h_fc1_drop = tf.nn.dropout(h_fc1, dropout_keep_prob)