New Push in 20241207

This commit is contained in:
whitekirin 2024-12-07 01:51:50 +08:00
parent ab05d5d87f
commit 7c0d37548b
44 changed files with 14 additions and 13 deletions

0
.hypothesis/unicode_data/13.0.0/charmap.json.gz Normal file → Executable file
View File

0
Calculate_Process/Calculate.py Normal file → Executable file
View File

0
Calculate_Process/__init__.py Normal file → Executable file
View File

View File

0
Calculate_Process/__pycache__/__init__.cpython-310.pyc Normal file → Executable file
View File

View File

View File

View File

0
Load_process/Load_Indepentend.py Normal file → Executable file
View File

0
Load_process/Loading_Tools.py Normal file → Executable file
View File

0
Load_process/__pycache__/LoadData.cpython-310.pyc Normal file → Executable file
View File

View File

0
Load_process/__pycache__/Loading_Tools.cpython-310.pyc Normal file → Executable file
View File

View File

0
Model_Loss/Loss.py Normal file → Executable file
View File

0
Model_Loss/__pycache__/Loss.cpython-310.pyc Normal file → Executable file
View File

0
Output_Class/Tqdm_Output_Class.py Normal file → Executable file
View File

View File

0
Processing_image.py Normal file → Executable file
View File

View File

View File

0
SCP_Process/Scp_Process.py Normal file → Executable file
View File

0
SCP_Process/__pycache__/Scp_Process.cpython-310.pyc Normal file → Executable file
View File

0
Training_Tools/Tools.py Normal file → Executable file
View File

0
Training_Tools/__init__.py Normal file → Executable file
View File

0
Training_Tools/__pycache__/Tools.cpython-310.pyc Normal file → Executable file
View File

0
Training_Tools/__pycache__/__init__.cpython-310.pyc Normal file → Executable file
View File

View File

0
all_models_tools/__pycache__/__init__.cpython-310.pyc Normal file → Executable file
View File

View File

View File

0
draw_tools/__pycache__/Grad_cam.cpython-310.pyc Normal file → Executable file
View File

0
draw_tools/__pycache__/__init__.cpython-310.pyc Normal file → Executable file
View File

0
draw_tools/__pycache__/draw.cpython-310.pyc Normal file → Executable file
View File

0
experiments/__pycache__/__init__.cpython-310.pyc Normal file → Executable file
View File

BIN
experiments/__pycache__/experiment.cpython-310.pyc Normal file → Executable file

Binary file not shown.

0
experiments/__pycache__/pytorch_Model.cpython-310.pyc Normal file → Executable file
View File

View File

@ -140,14 +140,14 @@ class experiments():
for inputs, labels in epoch_iterator: for inputs, labels in epoch_iterator:
labels = functional.one_hot(labels, self.Number_Of_Classes) OneHot_labels = functional.one_hot(labels, self.Number_Of_Classes)
# labels = np.reshape(labels, (int(labels.shape[0]), 1)) # labels = np.reshape(labels, (int(labels.shape[0]), 1))
inputs, labels = inputs.to(self.device), labels.to(self.device) inputs, OneHot_labels = inputs.to(self.device), OneHot_labels.to(self.device)
# inputs, labels = inputs.cuda(), labels.cuda() # inputs, labels = inputs.cuda(), labels.cuda()
Optimizer.zero_grad() Optimizer.zero_grad()
outputs = model(inputs) outputs = model(inputs)
loss = criterion(outputs, labels) loss = criterion(outputs, OneHot_labels)
loss.backward() loss.backward()
Optimizer.step() Optimizer.step()
running_loss += loss.item() running_loss += loss.item()
@ -159,7 +159,8 @@ class experiments():
Training_Loss = running_loss/len(Training) Training_Loss = running_loss/len(Training)
all_train_labels = torch.argmax(all_train_labels, 1) # all_train_labels = torch.FloatTensor(all_train_labels)
# all_train_labels = torch.argmax(all_train_labels, 1)
train_accuracy = accuracy_score(all_train_labels, all_train_preds) train_accuracy = accuracy_score(all_train_labels, all_train_preds)
train_losses.append(Training_Loss) train_losses.append(Training_Loss)
@ -174,11 +175,11 @@ class experiments():
with torch.no_grad(): with torch.no_grad():
for inputs, labels in self.Validation: for inputs, labels in self.Validation:
labels = np.reshape(labels, (int(labels.shape[0]), 1)) OneHot_labels = functional.one_hot(labels, self.Number_Of_Classes)
inputs, labels = inputs.to(self.device), labels.to(self.device) inputs, OneHot_labels = inputs.to(self.device), OneHot_labels.to(self.device)
outputs = model(inputs) outputs = model(inputs)
loss = criterion(outputs, labels) loss = criterion(outputs, OneHot_labels)
val_loss += loss.item() val_loss += loss.item()
# 驗證預測與標籤 # 驗證預測與標籤
@ -188,8 +189,6 @@ class experiments():
# 計算驗證損失與準確率 # 計算驗證損失與準確率
val_loss /= len(self.Validation) val_loss /= len(self.Validation)
all_val_labels = torch.argmax(all_val_labels, 1)
val_accuracy = accuracy_score(all_val_labels, all_val_preds) val_accuracy = accuracy_score(all_val_labels, all_val_preds)
val_losses.append(val_loss) val_losses.append(val_loss)
@ -212,19 +211,21 @@ class experiments():
True_Label, Predict_Label = [], [] True_Label, Predict_Label = [], []
loss = 0.0 loss = 0.0
with torch.no_grad(): with torch.no_grad():
for i, (images, labels) in enumerate(self.test): for images, labels in self.test:
OneHot_labels = functional.one_hot(labels, self.Number_Of_Classes)
images, OneHot_labels = images.to(self.device), OneHot_labels.to(self.device)
outputs = cnn_model(images) outputs = cnn_model(images)
_, predicted = torch.max(outputs.data, 1) _, predicted = torch.max(outputs, 1)
Predict_Label.extend(predicted.cpu().numpy()) Predict_Label.extend(predicted.cpu().numpy())
True_Label.extend(labels.cpu().numpy()) True_Label.extend(labels.cpu().numpy())
loss /= len(self.test) loss /= len(self.test)
all_val_labels = torch.argmax(all_val_labels, 1)
accuracy = accuracy_score(True_Label, Predict_Label) accuracy = accuracy_score(True_Label, Predict_Label)
precision = precision_score(True_Label, Predict_Label) precision = precision_score(True_Label, Predict_Label)
recall = recall_score(True_Label, Predict_Label) recall = recall_score(True_Label, Predict_Label)
AUC = auroc(True_Label, Predict_Label) AUC = auroc(True_Label, Predict_Label, task = ["Stomatch_Cancer", "Normal"])
f1 = f1_score(True_Label, Predict_Label) f1 = f1_score(True_Label, Predict_Label)
return loss, accuracy, precision, recall, AUC, f1, True_Label, Predict_Label return loss, accuracy, precision, recall, AUC, f1, True_Label, Predict_Label

0
experiments/pytorch_Model.py Normal file → Executable file
View File

0
merge_class/__pycache__/merge.cpython-310.pyc Normal file → Executable file
View File

View File

View File