最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

pytorch读数据接口制作数据集data.dataset

IT圈 admin 30浏览 0评论

2024年6月6日发(作者:竹浩涆)

32 # now load the picked numpy arrays

33 if :

34 _data = []

35 _labels = []

36 for fentry in _list:

37 f = fentry[0]

38 file = (, _folder, f)

39 fo = open(file, 'rb')

40 if n_info[0] == 2:

41 entry = (fo)

42 else:

43 entry = (fo, encoding='latin1')

44 _(entry['data'])

45 if 'labels' in entry:

46 _labels += entry['labels']

47 else:

48 _labels += entry['fine_labels']

49 ()

50

51 _data = enate(_data)

52 _data = _e((50000, 3, 32, 32))

53 _data = _ose((0, 2, 3, 1)) # convert to HWC

54 else:

55 f = _list[0][0]

56 file = (, _folder, f)

57 fo = open(file, 'rb')

58 if n_info[0] == 2:

59 entry = (fo)

60 else:

61 entry = (fo, encoding='latin1')

62 _data = entry['data']

63 if 'labels' in entry:

64 _labels = entry['labels']

65 else:

66 _labels = entry['fine_labels']

67 ()

68 _data = _e((10000, 3, 32, 32))

69 _data = _ose((0, 2, 3, 1)) # convert to HWC

70

71 def __getitem__(self, index):

72 """

73 Args:

74 index (int): Index

75

76 Returns:

77 tuple: (image, target) where target is index of the target class.

78 """

79 if :

80 img, target = _data[index], _labels[index]

81 else:

82 img, target = _data[index], _labels[index]

83

84 # doing this so that it is consistent with all other datasets

85 # to return a PIL Image

86 img = ray(img)

87

88 if orm is not None:

89 img = orm(img)

90

91 if _transform is not None:

92 target = _transform(target)

93

94 return img, target

2024年6月6日发(作者:竹浩涆)

32 # now load the picked numpy arrays

33 if :

34 _data = []

35 _labels = []

36 for fentry in _list:

37 f = fentry[0]

38 file = (, _folder, f)

39 fo = open(file, 'rb')

40 if n_info[0] == 2:

41 entry = (fo)

42 else:

43 entry = (fo, encoding='latin1')

44 _(entry['data'])

45 if 'labels' in entry:

46 _labels += entry['labels']

47 else:

48 _labels += entry['fine_labels']

49 ()

50

51 _data = enate(_data)

52 _data = _e((50000, 3, 32, 32))

53 _data = _ose((0, 2, 3, 1)) # convert to HWC

54 else:

55 f = _list[0][0]

56 file = (, _folder, f)

57 fo = open(file, 'rb')

58 if n_info[0] == 2:

59 entry = (fo)

60 else:

61 entry = (fo, encoding='latin1')

62 _data = entry['data']

63 if 'labels' in entry:

64 _labels = entry['labels']

65 else:

66 _labels = entry['fine_labels']

67 ()

68 _data = _e((10000, 3, 32, 32))

69 _data = _ose((0, 2, 3, 1)) # convert to HWC

70

71 def __getitem__(self, index):

72 """

73 Args:

74 index (int): Index

75

76 Returns:

77 tuple: (image, target) where target is index of the target class.

78 """

79 if :

80 img, target = _data[index], _labels[index]

81 else:

82 img, target = _data[index], _labels[index]

83

84 # doing this so that it is consistent with all other datasets

85 # to return a PIL Image

86 img = ray(img)

87

88 if orm is not None:

89 img = orm(img)

90

91 if _transform is not None:

92 target = _transform(target)

93

94 return img, target

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论