1 Star 0 Fork 10

yuhu521mx/双色球预测

forked from Fu_Yanbo/双色球预测 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
SSQDataset.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Fu_Yanbo 提交于 2022-08-07 13:00 . Default Changelist
import torch
from torch.utils.data import Dataset
from tools import ReadIntArray, OneHotData
class SSQDataset(Dataset):
def __init__(self, file_path, my_detection, sample_nums):
self.file_path = file_path
self.my_detection = my_detection
self.sample_nums = sample_nums
self.my_list = ReadIntArray(self.file_path)
def __getitem__(self, my_index):
data_list = []
target_list = []
start_index = my_index
for sample_num in range(self.sample_nums):
data_list.append(self.my_list[start_index + sample_num])
if self.my_detection in self.my_list[start_index + self.sample_nums]:
target_list = [1, 0]
else:
target_list = [0, 1]
data_list = OneHotData(data_list)
data_list = torch.tensor(data_list, dtype=torch.float32)
target_list = torch.tensor(target_list, dtype=torch.float32)
return data_list, target_list
def __len__(self):
return len(self.my_list) - self.sample_nums
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yuhu_521_mx/ssq.git
git@gitee.com:yuhu_521_mx/ssq.git
yuhu_521_mx
ssq
双色球预测
master

搜索帮助