【发布时间】:2019-07-24 09:51:38
【问题描述】:
我有一个包含特征和标签的数据集。我想从中产生三样东西:
x,y,lb = train_data
我的train_data具有索引中的特征和标签,比如0 to 100。我希望x 有来自1 to 100 的feature 样本,y 应该有来自0 to 99 的labels 和lb 应该有索引100 的标签。
此外,我想使用迭代器在滑动批次中执行此操作。目前我有以下代码从0 to 100和y从0 to 100生成x。下一批从x : 1 to 101和y:1 to 101开始,以此类推。
features_placeholder = tf.placeholder(tf.float32, shape=[None,None],name="input_features")
labels_placeholder = tf.placeholder(tf.float32, shape=[None,1],name = "input_labels")
iterator = (tf.data.Dataset.from_tensor_slices((features_placeholder, labels_placeholder))
.apply(sliding.sliding_window_batch(timestep=100, stride=1))
.batch(10)
.make_initializable_iterator()
)
next_element = iterator.get_next(name="batch")
init_op = iterator.initializer
saveable = tf.contrib.data.make_saveable_from_iterator(iterator)
【问题讨论】:
标签: python python-3.x tensorflow tensorflow-datasets