tensorflow输入数据处理

A = tf.data.Dataset.from_generator(lambda: [['1,2'],['3,4,5']], tf.string, output_shapes=[None])
B = (A.map(lambda x: tf.string_to_number(tf.string_split(x, ',').values, tf.int64) )
     .repeat(100)
    .padded_batch(2,[None])
  )
it = B.make_one_shot_iterator()
one = it.get_next()
with tf.Session() as sess:
    x = sess.run(one)
    y = sess.run(one)
    print(x)
    print(y)

  • 手工设置shape
cate_id.set_shape([None,200])
原文地址:https://www.cnblogs.com/bregman/p/10412260.html