Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用tf.data.Dataset.interleave从tf2中的多个数据集对象中进行子采样?_Python 3.x_Tensorflow Datasets_Tensorflow2.x_Subsampling - Fatal编程技术网

Python 3.x 如何使用tf.data.Dataset.interleave从tf2中的多个数据集对象中进行子采样?

Python 3.x 如何使用tf.data.Dataset.interleave从tf2中的多个数据集对象中进行子采样?,python-3.x,tensorflow-datasets,tensorflow2.x,subsampling,Python 3.x,Tensorflow Datasets,Tensorflow2.x,Subsampling,我尝试复制使用tf.data.Dataset.interleave发布的解决方案,但不太确定如何将interleave方法应用于已创建的数据集对象。 代码如下: import tensorflow as tf import numpy as np # preparing data train, test = tf.keras.datasets.fashion_mnist.load_data() images, labels = train images = images/255 datase

我尝试复制使用tf.data.Dataset.interleave发布的解决方案,但不太确定如何将interleave方法应用于已创建的数据集对象。 代码如下:

import tensorflow as tf
import numpy as np

# preparing data
train, test = tf.keras.datasets.fashion_mnist.load_data()
images, labels = train
images = images/255

dataset = tf.data.Dataset.from_tensor_slices((images, labels))

class0=lambda features, label: label==0
class1=lambda features, label: label==1
class2=lambda features, label: label==2

ds_0=dataset.filter(class0)
ds_1=dataset.filter(class1)
ds_2=dataset.filter(class2)
我想通过从ds_0、ds_1和ds_2中进行相等采样来创建一个数据集。我应该传递什么作为
map\u func