本文整理匯總了Python中data_utils.get_input_fn方法的典型用法代碼示例。如果您正苦於以下問題:Python data_utils.get_input_fn方法的具體用法?Python data_utils.get_input_fn怎麽用?Python data_utils.get_input_fn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類data_utils
的用法示例。
在下文中一共展示了data_utils.get_input_fn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_input_fn
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import get_input_fn [as 別名]
def get_input_fn(split):
"""doc."""
assert split == "train"
batch_size = FLAGS.train_batch_size
input_fn, record_info_dict = data_utils.get_input_fn(
tfrecord_dir=FLAGS.record_info_dir,
split=split,
bsz_per_host=batch_size // FLAGS.num_hosts,
seq_len=FLAGS.seq_len,
reuse_len=FLAGS.reuse_len,
bi_data=FLAGS.bi_data,
num_hosts=FLAGS.num_hosts,
num_core_per_host=FLAGS.num_core_per_host,
perm_size=FLAGS.perm_size,
mask_alpha=FLAGS.mask_alpha,
mask_beta=FLAGS.mask_beta,
uncased=FLAGS.uncased,
num_passes=FLAGS.num_passes,
use_bfloat16=FLAGS.use_bfloat16,
num_predict=FLAGS.num_predict)
return input_fn, record_info_dict
示例2: main
# 需要導入模塊: import data_utils [as 別名]
# 或者: from data_utils import get_input_fn [as 別名]
def main(unused_argv):
del unused_argv # Unused
tf.logging.set_verbosity(tf.logging.INFO)
assert FLAGS.seq_len > 0
assert FLAGS.perm_size > 0
FLAGS.n_token = data_utils.VOCAB_SIZE
tf.logging.info("n_token {}".format(FLAGS.n_token))
if not tf.gfile.Exists(FLAGS.model_dir):
tf.gfile.MakeDirs(FLAGS.model_dir)
# Get train input function
train_input_fn, train_record_info_dict = get_input_fn("train")
tf.logging.info("num of batches {}".format(
train_record_info_dict["num_batch"]))
# Get train cache function
train_cache_fn = get_cache_fn(FLAGS.mem_len)
##### Get model function
model_fn = get_model_fn()
##### Create TPUEstimator
# TPU Configuration
run_config = model_utils.configure_tpu(FLAGS)
# TPU Estimator
estimator = tpu_estimator.TPUEstimator(
model_fn=model_fn,
train_cache_fn=train_cache_fn,
use_tpu=FLAGS.use_tpu,
config=run_config,
params={"track_mean": FLAGS.track_mean},
train_batch_size=FLAGS.train_batch_size,
eval_on_tpu=FLAGS.use_tpu)
#### Training
estimator.train(input_fn=train_input_fn, max_steps=FLAGS.train_steps)