tensorflow - Replacing input pipeline at test (tf.contrib.data without placeholders) -
i'm using tf.contrib.data functions input pipeline during training (without placeholders). question how reuse trained model , feed in new data @ test time? question similar this one except not use placeholders @ test either - test dataset large , slowdown of placeholders should avoided there well.
is there way replace input pipeline new 1 @ test?
i not sure if there optimum way solve problem, how solved it:
in model i'm using simple mlp, model() function has lines in it:
train_layer = tf.add(tf.matmul(x_train, weights['w1']), biases['b1']) train_layer = tf.nn.relu(train_layer) test_layer = tf.add(tf.matmul(x_test, weights['w1']), biases['b1']) test_layer = tf.nn.relu(test_layer) as can see, have 2 inputs, x_train, , x_test. these handles batches of data tf.contrib.data dataset iterator:
x_train, x_train_labels = train_iter.get_next() x_test, x_test_labels = test_iter.get_next() so have 2 flows of data in same graph, exact same operations performed on. have 2 outputs of model, mlp_train , mlp_test depending on whether model evaluated using x_train or x_test inputs.
now: if create optimiser using mlp_train output, , create testing metrics using mlp_test outputs, need run: sess.run(optimiser) train system on training dataset, , sess.run(test_metrics) test system on testing dataset, , never need use feed_dict.
edit: read comment using "data not available when model trained", , don't think answer satisfies that.
Comments
Post a Comment