我正在使用TensorFlow训练卷积神经网络,将建筑物图像分为5类.
Training dataset:
Class 1 - 3000 images
Class 2 - 3000 images
Class 3 - 3000 images
Class 4 - 3000 images
Class 5 - 3000 images
Run Code Online (Sandbox Code Playgroud)
我从一个非常简单的架构开始:
Input image - 256 x 256 x 3
Convolutional layer 1 - 128 x 128 x 16 (3x3 filters, 16 filters, stride=2)
Convolutional layer 2 - 64 x 64 x 32 (3x3 filters, 32 filters, stride=2)
Convolutional layer 3 - 32 x 32 x 64 (3x3 filters, 64 filters, …Run Code Online (Sandbox Code Playgroud) machine-learning neural-network deep-learning conv-neural-network tensorflow
import tensorflow as tf
sess = tf.Session()
def add_to_batch(image):
print('Adding to batch')
image_batch = tf.train.shuffle_batch([image],batch_size=5,capacity=11,min_after_dequeue=1,num_threads=1)
# Add to summary
tf.image_summary('images',image_batch)
return image_batch
def get_batch():
# Create filename queue of images to read
filenames = [('/media/jessica/Jessica/TensorFlow/Practice/unlabeled_data_%d.png' % i) for i in range(11)]
filename_queue = tf.train.string_input_producer(filenames)
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
# Read and process image
my_image = tf.image.decode_png(value)
my_image_float = tf.cast(my_image,tf.float32)
image_mean = tf.reduce_mean(my_image_float)
my_noise = tf.random_normal([96,96,3],mean=image_mean)
my_image_noisy = my_image_float + my_noise
print('Reading images')
return add_to_batch(my_image_noisy)
def main (): …Run Code Online (Sandbox Code Playgroud)