Skip to content

Commit 1a110c1

Browse files
committed
初始化
1 parent a02042b commit 1a110c1

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎NeurNetWorkProcess/ProceRawDataToTensor.py‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import csv
44
import numpy as np
5+
import random
56

67
Work_Path = "F:\\PlantarPressurePredictExperiment"
78
os.chdir(Work_Path)
@@ -103,7 +104,9 @@ def switchLabelClass(label):
103104

104105
#f = GetFileIterator(dic)
105106
#a = f.__next__()
106-
i= 0
107+
randomCount = 0
108+
selectFlag = False
109+
randomList = [0, 1, 2, 3, 4]
107110

108111
for eachItem in GetFileIterator(dic):
109112
Arr = eachItem[5]
@@ -112,14 +115,26 @@ def switchLabelClass(label):
112115

113116
mean = Arr.mean()
114117
std = Arr.std()
115-
Arr = (Arr - mean)/std #标准化数据
116-
i +=1
117-
if(i % 5 != 0):
118+
Arr = (Arr - mean) / std # 标准化数据
119+
120+
randomCount += 1
121+
if (randomCount % 5 == 0): # 每5个重置一次抽取
122+
selectFlag = False
123+
randomList = [0, 1, 2, 3, 4]
124+
125+
if not selectFlag:
126+
randomIndex = random.choice(randomList)
127+
randomList.remove(randomIndex)
128+
if (randomIndex == 0):
129+
TestArr.append(Arr)
130+
TestAngle.append(label)
131+
selectFlag = True # 这一轮次已经抽取了测试集
132+
else:
133+
TrainArr.append(Arr)
134+
TrainAngle.append(label)
135+
else:
118136
TrainArr.append(Arr)
119137
TrainAngle.append(label)
120-
else:
121-
TestArr.append(Arr)
122-
TestAngle.append(label)
123138

124139
TrainArr = np.array(TrainArr)
125140
TrainAngle = np.array(TrainAngle)

‎PreProcess/DataProcessFile.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55

66
#设置工作环境
7-
Work_Path = "/"
7+
Work_Path = "F:\\PlantarPressurePredictExperiment"
88
os.chdir(Work_Path)
99

1010
def DataProcess(name):
@@ -57,7 +57,7 @@ def WriteFrames(FramesList,savePathAndName):
5757

5858

5959
if __name__ == '__main__':
60-
for l in ['10','11','12']: #3-9
60+
for l in ['01','02','03','04','05','06','07','08','09','10','11','12']: #1-12
6161
subject = "subject{}".format(l)
6262
for i in range(1, 12): # 1-11
6363
print(subject)

0 commit comments

Comments
 (0)