def load_vehicle_data(): # Load data from file # Make sure that vehicles.dat is in data/ train_x, train_y, test_x, test_y = get_vehicle_data() num_train = train_x.shape[0] num_test = test_x.shape[0] #generate_unit_testcase(train_x.copy(), train_y.copy()) # Normalize our data: choose one of the two methods before training #train_x, test_x = normalize_all_pixel(train_x, test_x) train_x, test_x = normalize_per_pixel(train_x, test_x) # Reshape our data # train_x: shape=(2400, 64, 64) -> shape=(2400, 64*64) # test_x: shape=(600, 64, 64) -> shape=(600, 64*64) train_x = reshape2D(train_x) test_x = reshape2D(test_x) # Pad 1 as the last feature of train_x and test_x train_x = add_one(train_x) test_x = add_one(test_x) return train_x, train_y, test_x, test_y
# gt_zero = (x > zeros) # relu_logits = tf.where(gt_zero, x, zeros) # neg_abs = tf.where(gt_zero, -x, x) # c = tf.reduce_mean(relu_logits - tf.multiply(x, L) + tf.log(1 + tf.exp(neg_abs))) return tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits( labels=y, logits=logits)) if __name__ == "__main__": np.random.seed(2018) tf.set_random_seed(2018) # Load data from file # Make sure that vehicles.dat is in data/ train_x, train_y, test_x, test_y = get_vehicle_data() num_train = train_x.shape[0] num_test = test_x.shape[0] #generate_unit_testcase(train_x.copy(), train_y.copy()) #logistic_unit_test() # Normalize our data: choose one of the two methods before training #train_x, test_x = normalize_all_pixel(train_x, test_x) train_x, test_x = normalize_per_pixel(train_x, test_x) # Reshape our data # train_x: shape=(2400, 64, 64) -> shape=(2400, 64*64) # test_x: shape=(600, 64, 64) -> shape=(600, 64*64) train_x = reshape2D(train_x) test_x = reshape2D(test_x)
test_dict['y_hat'] = y_hat test_dict['loss'] = loss test_dict['grad'] = grad testcase['output'].append(test_dict) np.save('./data/logistic_unittest.npy', testcase) if __name__ == "__main__": np.random.seed(2018) # Load data from file # Make sure that vehicles.dat is in data/ train_x, train_y, test_x, test_y = get_vehicle_data() num_train = train_x.shape[0] num_test = test_x.shape[0] #generate_unit_testcase(train_x.copy(), train_y.copy()) #logistic_unit_test() # Normalize our data: choose one of the two methods before training #train_x, test_x = normalize_all_pixel(train_x, test_x) train_x, test_x = normalize_per_pixel(train_x, test_x) # Reshape our data # train_x: shape=(2400, 64, 64) -> shape=(2400, 64*64) # test_x: shape=(600, 64, 64) -> shape=(600, 64*64) train_x = reshape2D(train_x) test_x = reshape2D(test_x)