为了账号安全,请及时绑定邮箱和手机立即绑定

TypeError: unhashable type: 'list' 调用 .iloc() 时

TypeError: unhashable type: 'list' 调用 .iloc() 时

catspeake 2021-06-15 13:05:31
我目前正在为一个项目做一些 AI 研究,为此我必须习惯一个名为“Pytorch”的框架。这很好,除了按照官方教程(在此处找到)之外,代码无法正常运行。这个想法是我从准备好的数据集中分析一组面部特征,然后用它做一些事情(还没有达到那个部分)。但是当我运行这段代码时:img_name = os.path.join(self.root_dir, self.landmarks_frame.iloc([index, 0]))  # At this point 'index' is 0数据集初始化如下:face_dataset = fDataset(csv_file='faces/face_landmarks.csv', root_dir='faces/')这是弹出错误的地方:for i in range(len(face_dataset)):    sample = face_dataset[i]  # <-- right there这导致了 getter 函数:def __getitem__(self, index):    img_name = os.path.join(self.root_dir, self.landmarks_frame.iloc([index, 0]))    image = io.imread(img_name)    landmarks = self.landmarks_frame.iloc[index, 1:].as_matrix()    landmarks = landmarks.astype('float').reshape(-1, 2)    sample = {'image': image, 'landmarks': landmarks}在我的FaceLandmarksDataset(Dataset):课堂上发现我只是得到了标题的错误。我发现这很奇怪,因为我可以在 PyCharm 中将数据集作为框架读取:第一张图清晰可见的地方。我也检查过它是否在我正在查看的文件夹中。任何人都可以帮忙吗?:)
查看完整描述

1 回答

?
一只甜甜圈

TA贡献1836条经验 获得超5个赞

您不需要括号iloc

self.landmarks_frame.iloc[index, 0]


查看完整回答
反对 回复 2021-06-22
  • 1 回答
  • 0 关注
  • 147 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信