problem description
Import the picture into the program while training the size of the batch_size
but this has always been the case
2018-09-06 15 T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141 12 br 24.930926: I T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-09-06 15 T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141 1225.951985: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 1511424000 exceeds 10% of system memory.
the environmental background of the problems and what methods you have tried
I used the TFRecords method
related codes
def read_and_decode(filename):
filename_queue = tf.train.string_input_producer([filename])
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(serialized_example,
features={
"label": tf.FixedLenFeature([], tf.int64),
"img_raw" : tf.FixedLenFeature([], tf.string),
})
img = tf.decode_raw(features["img_raw"], tf.uint8)
img = tf.reshape(img, [600, 328, 1])
img = tf.cast(img, tf.float32) * (1. / 255) - 0.5
label = tf.cast(features["label"], tf.int32)
return img, label
if __name__ == "__main__":
img, label = read_and_decode("train.tfrecords")
img_train, label_train = tf.train.shuffle_batch([img, label],
batch_size=30, capacity=2000,
min_after_dequeue=1000)
print("begin")
print("begin data")
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)
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides = [1, 1, 1, 1], padding = "SAME")
def max_pool_2x2(x):
return tf.nn.max_pool(x, ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = "SAME")
def avg_pool_82x150(x):
return tf.nn.avg_pool(x, ksize = [1, 150, 82, 1], strides = [1, 150, 82, 1], padding = "SAME")
x = tf.placeholder(tf.float32, [None, 600, 328, 1])
y = tf.placeholder(tf.float32, [None, 6])
W_conv1 = weight_variable([5, 5, 1, 64])
b_conv1 = bias_variable([64])
x_image = tf.reshape(x, [-1, 600, 328, 1])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)
W_conv2 = weight_variable([5, 5, 64, 64])
b_conv2 = bias_variable([64])
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2)
W_conv3 = weight_variable([5, 5, 64, 6])
b_conv3 = bias_variable([6])
h_conv3 = tf.nn.relu(conv2d(h_pool2, W_conv3) + b_conv3)
-sharp 82*150
nt_hpool3 = avg_pool_82x150(h_conv3)
nt_hpool3_flat = tf.reshape(nt_hpool3, [-1, 6])
y_conv = tf.nn.softmax(nt_hpool3_flat)
cross_entropy = -tf.reduce_sum(y*tf.log(y_conv))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
-sharp
sess = tf.Session()
sess.run(tf.global_variables_initializer())
tf.train.start_queue_runners(sess = sess)
for i in range(1000):
image_batch, label_batch = sess.run([img_train, label_train])
label_b = np.eye(6, dtype =float)[label_batch]
train_step.run(feed_dict = {x:image_batch, y:label_b},session = sess)
if i%200 == 0:
train_accuracy = accuracy.eval(feed_dict = {x:image_batch, y:label_b}, session = sess)
print("step %d, training accuracy %g" %(i, train_accuracy))
what result do you expect? What is the error message actually seen?
first the memory is full
and then there is begin
begin data
2018-09-06 15br 25br 13.005857: I T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-09-06 1515 of system memory.: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 1511424000 exceeds 10% of system memory.
2018-09-06 1515 of system memory.: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 377856000 exceeds 10% of system memory.
2018-09 -06 15 exceeds 25 of system memory. 15.974027: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 377856000 exceeds 10% of system memory.
2018-09-06 15 exceeds 2531.735929: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 377856000 exceeds 10% of system memory.
2018-09-06 15 Swiss 2535.883166: W T:srcgithubtensorflowtensorflowcoreframeworkallocator.cc:108] Allocation of 377856000 exceeds 10% of system memory.
step 0, Training accuracy 0.0333333
just stays stuck