Ich versuche ein einfaches Beispiel für ein Buch, wo ich eine Zugdatenprobe mit 892 Zeilen, das übliche titanic Survival Lehrbuch Beispiel habe. Ich definiere:tensorflow Lauf dauert ewig auf kleine Daten
def read_csv(batch_size, file_path, record_defaults):
filename_queue = tf.train.string_input_producer([file_path])
reader = tf.TextLineReader(skip_header_lines=1)
key, value = reader.read(filename_queue)
# decode_csv will convert a Tensor from type string (the text line) in
# a tuple of tensor columns with the specified defaults, which also
# sets the data type for each column
decoded = tf.decode_csv(value, record_defaults=record_defaults)
# batch actually reads the file and loads "batch_size" rows in a single tensor
return tf.train.shuffle_batch(decoded,
batch_size=batch_size,
capacity=batch_size * 50,
min_after_dequeue=batch_size)
def inputs():
passenger_id, survived, pclass, name, sex, age, sibsp, parch, ticket, fare, cabin, embarked = \
read_csv(BATCH_SIZE, file_path, record_defaults)
# convert categorical data
is_first_class = tf.to_float(tf.equal(pclass, [1]))
is_second_class = tf.to_float(tf.equal(pclass, [2]))
is_third_class = tf.to_float(tf.equal(pclass, [3]))
gender = tf.to_float(tf.equal(sex, ["female"]))
# Finally we pack all the features in a single matrix;
# We then transpose to have a matrix with one example per row and one feature per column.
features = tf.transpose(tf.pack([is_first_class, is_second_class, is_third_class, gender, age]))
print 'shape of features', features.get_shape()
return features, survived
Und ich versuche jetzt zu tun:
graph = tf.Graph()
with tf.Session(graph=graph) as sess:
W = tf.Variable(tf.zeros([5, 1]), name="weights")
b = tf.Variable(0., name="bias")
tf.global_variables_initializer().run()
print 'tf was run'
X,Y = inputs()
print 'inputs!'
sess.run(Y)
und ich sehe
'tf was run!'
'inputs!'
aber der run
Teil hängt immer (oder zumindest eine sehr lange tiem). Ich führe dies auf Jupyter mit einem 2.7 Kernel und tf
Version 0.12
Was fehlt mir?
Oder verwenden Sie 'tf.train.MonitoredTrainingSession', die dafür sorgt, von die gesamte Initialisierung und das Starten von Warteschlangenläufern. – Nandeesh