本文整理匯總了Python中data_utils.generate_feed_dict方法的典型用法代碼示例。如果您正苦於以下問題:Python data_utils.generate_feed_dict方法的具體用法?Python data_utils.generate_feed_dict怎麽用?Python data_utils.generate_feed_dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類data_utils
的用法示例。
在下文中一共展示了data_utils.generate_feed_dict方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: evaluate
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import generate_feed_dict [as 別名]
def evaluate(sess, data, batch_size, graph, i):
#computes accuracy
num_examples = 0.0
gc = 0.0
for j in range(0, len(data) - batch_size + 1, batch_size):
[ct] = sess.run([graph.final_correct],
feed_dict=data_utils.generate_feed_dict(data, j, batch_size,
graph))
gc += ct * batch_size
num_examples += batch_size
print "dev set accuracy after ", i, " : ", gc / num_examples
print num_examples, len(data)
print "--------"
示例2: Train
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import generate_feed_dict [as 別名]
def Train(graph, utility, batch_size, train_data, sess, model_dir,
saver):
#performs training
curr = 0
train_set_loss = 0.0
utility.random.shuffle(train_data)
start = time.time()
for i in range(utility.FLAGS.train_steps):
curr_step = i
if (i > 0 and i % FLAGS.write_every == 0):
model_file = model_dir + "/model_" + str(i)
saver.save(sess, model_file)
if curr + batch_size >= len(train_data):
curr = 0
utility.random.shuffle(train_data)
step, cost_value = sess.run(
[graph.step, graph.total_cost],
feed_dict=data_utils.generate_feed_dict(
train_data, curr, batch_size, graph, train=True, utility=utility))
curr = curr + batch_size
train_set_loss += cost_value
if (i > 0 and i % FLAGS.eval_cycle == 0):
end = time.time()
time_taken = end - start
print "step ", i, " ", time_taken, " seconds "
start = end
print " printing train set loss: ", train_set_loss / utility.FLAGS.eval_cycle
train_set_loss = 0.0
示例3: evaluate
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import generate_feed_dict [as 別名]
def evaluate(sess, data, batch_size, graph, i):
#computes accuracy
num_examples = 0.0
gc = 0.0
for j in range(0, len(data) - batch_size + 1, batch_size):
[ct] = sess.run([graph.final_correct],
feed_dict=data_utils.generate_feed_dict(data, j, batch_size,
graph))
gc += ct * batch_size
num_examples += batch_size
print("dev set accuracy after ", i, " : ", gc / num_examples)
print(num_examples, len(data))
print("--------")
示例4: Train
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import generate_feed_dict [as 別名]
def Train(graph, utility, batch_size, train_data, sess, model_dir,
saver):
#performs training
curr = 0
train_set_loss = 0.0
utility.random.shuffle(train_data)
start = time.time()
for i in range(utility.FLAGS.train_steps):
curr_step = i
if (i > 0 and i % FLAGS.write_every == 0):
model_file = model_dir + "/model_" + str(i)
saver.save(sess, model_file)
if curr + batch_size >= len(train_data):
curr = 0
utility.random.shuffle(train_data)
step, cost_value = sess.run(
[graph.step, graph.total_cost],
feed_dict=data_utils.generate_feed_dict(
train_data, curr, batch_size, graph, train=True, utility=utility))
curr = curr + batch_size
train_set_loss += cost_value
if (i > 0 and i % FLAGS.eval_cycle == 0):
end = time.time()
time_taken = end - start
print("step ", i, " ", time_taken, " seconds ")
start = end
print(" printing train set loss: ", train_set_loss / utility.FLAGS.eval_cycle)
train_set_loss = 0.0