减少CNN训练时,测试集的内存占用
This commit is contained in:
@@ -5,6 +5,7 @@ from tqdm import tqdm
|
||||
import generate
|
||||
import forward
|
||||
import cv2
|
||||
import sys
|
||||
import numpy as np
|
||||
print("Finish!")
|
||||
|
||||
@@ -61,8 +62,6 @@ MOVING_AVERAGE_DECAY = 0.99
|
||||
|
||||
|
||||
def train(dataset, show_bar=False):
|
||||
test_images, test_labels = dataset.all_test_sets()
|
||||
|
||||
x = tf.placeholder(tf.float32, [None, generate.SRC_ROWS, generate.SRC_COLS, generate.SRC_CHANNELS])
|
||||
y_= tf.placeholder(tf.float32, [None, forward.OUTPUT_NODES])
|
||||
nodes, vars = forward.forward(x, 0.001)
|
||||
@@ -104,15 +103,10 @@ def train(dataset, show_bar=False):
|
||||
|
||||
if i % 100 == 0:
|
||||
if i % 1000 == 0:
|
||||
acc = sess.run(accuracy, feed_dict={x: test_images, y_: test_labels})
|
||||
test_samples, test_labels = dataset.sample_test_sets(5000)
|
||||
acc = sess.run(accuracy, feed_dict={x: test_samples, y_: test_labels})
|
||||
bar.set_postfix({"loss": loss_value, "acc": acc})
|
||||
|
||||
|
||||
# if show_bar:
|
||||
# bar.title = "step: %d, loss: %f, acc: %f" % (step, loss_value, acc)
|
||||
# bar.cursor.restore()
|
||||
# bar.draw(value=i+1)
|
||||
|
||||
# video = cv2.VideoCapture("/home/xinyang/Desktop/Video.mp4")
|
||||
# _ = True
|
||||
# while _:
|
||||
@@ -148,11 +142,12 @@ def train(dataset, show_bar=False):
|
||||
# res = sess.run(y, feed_dict={x: im})
|
||||
# res = res.reshape([forward.OUTPUT_NODES])
|
||||
# print(np.argmax(res))
|
||||
|
||||
|
||||
test_samples, test_labels = dataset.sample_test_sets(100)
|
||||
vars_val = sess.run(vars)
|
||||
save_para("/home/xinyang/Desktop/AutoAim/tools/para", vars_val)
|
||||
nodes_val = sess.run(nodes, feed_dict={x:test_images})
|
||||
return vars_val, nodes_val
|
||||
nodes_val = sess.run(nodes, feed_dict={x:test_samples})
|
||||
return vars_val, nodes_val, test_samples
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -160,3 +155,4 @@ if __name__ == "__main__":
|
||||
dataset = generate.DataSet("/home/xinyang/Desktop/DataSets/box")
|
||||
print("Finish!")
|
||||
train(dataset, show_bar=True)
|
||||
input("Press any key to end...")
|
||||
|
||||
Reference in New Issue
Block a user