-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
80 lines (63 loc) · 1.87 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from xrd_analyzer.data.data_loader import get_data_loader
from xrd_analyzer.models.cnn_classification import CNN
from xrd_analyzer.training.train import Trainer
import torch
import torch.nn as nn
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
train_dataloader = get_data_loader(data='train', batch_size=128)
batch = next(iter(train_dataloader))
X = batch[0]
X = X.view(X.shape[0], 1, X.shape[1])
print("Initial")
print(X.shape)
X = X.to(device, dtype=torch.float)
conv1 = nn.Sequential(
nn.Conv1d(in_channels=1, out_channels=10, kernel_size=3, stride=1, padding=1),
nn.BatchNorm1d(10),
nn.ReLU())
conv2 = nn.Sequential(
nn.Conv1d(in_channels=10, out_channels=10, kernel_size=3, stride=1, padding=1),
nn.BatchNorm1d(10),
nn.ReLU(),
nn.MaxPool1d(kernel_size=3, stride=2, padding=1))
conv3 = nn.Sequential(
nn.Conv1d(in_channels=10, out_channels=10, kernel_size=3, stride=1, padding=1),
nn.BatchNorm1d(10),
nn.ReLU(),
nn.MaxPool1d(kernel_size=4, stride=2, padding=1))
conv4 = nn.Sequential(
nn.Conv1d(in_channels=10, out_channels=10, kernel_size=3, stride=1, padding=1),
nn.BatchNorm1d(10),
nn.ReLU(),
nn.MaxPool1d(kernel_size=5, stride=2, padding=1))
conv1 = conv1.to(device)
conv2 = conv2.to(device)
conv3 = conv3.to(device)
conv4 = conv4.to(device)
print("1st pass")
X = conv1(X)
print(X.shape)
print("2nd pass")
X = conv3(X)
print(X.shape)
print("3rd pass")
X = conv2(X)
print(X.shape)
print("4th pass")
X = conv3(X)
print(X.shape)
print("5th pass")
X = conv2(X)
print(X.shape)
print("6th pass")
X = conv2(X)
print(X.shape)
print("7th pass")
X = conv2(X)
print(X.shape)
print("8th pass")
X = conv3(X)
print(X.shape)
print("9th pass")
X = conv2(X)
print(X.shape)