Dataframe 映射Dataset.from_tensor_切片元组

Dataframe 映射Dataset.from_tensor_切片元组,dataframe,tensorflow,dictionary,dataset,Dataframe,Tensorflow,Dictionary,Dataset,我正试图用这首图图中的tensorflow创建一个分段学习,但我无法映射我的数据帧(id,pic1_路径,pic2_路径)[1332行x 2列] def preprocessing(carte_path, mask_path): carte_img = rasterio.open(carte_path) carte_img = ToTensor() (carte_img) mask_img = rasterio.open(mask_path) mask_img = To

我正试图用这首图图中的tensorflow创建一个分段学习,但我无法映射我的数据帧(id,pic1_路径,pic2_路径)[1332行x 2列]

def preprocessing(carte_path, mask_path):
   carte_img = rasterio.open(carte_path)
   carte_img = ToTensor() (carte_img)

   mask_img = rasterio.open(mask_path)
   mask_img = ToTensor() (mask_img)

return carte_img, mask_img
这就是如何从数据帧创建数据集

    ds = tf.data.Dataset.from_tensor_slices((df["carte_path"].values, df["mask_path"].values))
    ds = tf.map_fn(preprocessing,ds)
通过上面的代码,我得到了以下错误:

ValueError:只有秩>=1时才支持取消数据集的匹配

我还尝试将数据集的map函数用作:

    ds = tf.data.Dataset.from_tensor_slices((df["carte_path"].values, df["mask_path"].values))
    ds = ds.map(preprocessing,tf.data.AUTOTUNE)
但预处理得到的路径无效:
TypeError:路径或文件无效:

我正在使用tiff数据,因此正常功能无法打开文件