dyaminda commited on
Commit
64bddab
1 Parent(s): d71f13c

End of training

Browse files
README.md CHANGED
@@ -15,7 +15,7 @@ should probably proofread and complete it, then remove this comment. -->
15
 
16
  This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
17
  It achieves the following results on the evaluation set:
18
- - Loss: 0.4359
19
  - Accuracy: 0.7426
20
 
21
  ## Model description
@@ -50,7 +50,7 @@ The following hyperparameters were used during training:
50
 
51
  | Training Loss | Epoch | Step | Validation Loss | Accuracy |
52
  |:-------------:|:-----:|:----:|:---------------:|:--------:|
53
- | 0.4504 | 0.99 | 52 | 0.4243 | 0.7494 |
54
 
55
 
56
  ### Framework versions
 
15
 
16
  This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
17
  It achieves the following results on the evaluation set:
18
+ - Loss: 0.4282
19
  - Accuracy: 0.7426
20
 
21
  ## Model description
 
50
 
51
  | Training Loss | Epoch | Step | Validation Loss | Accuracy |
52
  |:-------------:|:-----:|:----:|:---------------:|:--------:|
53
+ | 0.4432 | 0.99 | 52 | 0.4172 | 0.7494 |
54
 
55
 
56
  ### Framework versions
config.json CHANGED
@@ -2,6 +2,10 @@
2
  "architectures": [
3
  "AlexNetPneumoniaClassification"
4
  ],
 
 
 
 
5
  "input_channels": 3,
6
  "model_type": "alexnet",
7
  "num_classes": 2,
 
2
  "architectures": [
3
  "AlexNetPneumoniaClassification"
4
  ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_alexnet.AlexNetConfig",
7
+ "AutoModelForImageClassification": "modeling_alexnet.AlexNetPneumoniaClassification"
8
+ },
9
  "input_channels": 3,
10
  "model_type": "alexnet",
11
  "num_classes": 2,
configuration_alexnet.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # create pretrainconfig
2
+ from transformers import PretrainedConfig
3
+
4
+ class AlexNetConfig(PretrainedConfig):
5
+ model_type = "alexnet"
6
+ def __init__(self, **kwargs):
7
+ self.num_classes = 2
8
+ self.input_channels = 3
9
+ self.output_hidden_states = True
10
+ self.return_dict = True
11
+ self.id2label={0: "normal", 1: "pneumonia"}
12
+ self.label2id={"normal": 0, "pneumonia": 1}
13
+ self.num_labels = 2
14
+ self.model_type = "alexnet"
15
+ super().__init__(**kwargs)
modeling_alexnet.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch.nn as nn
2
+ import torch
3
+ from transformers.modeling_outputs import SequenceClassifierOutput
4
+ from transformers.modeling_utils import PreTrainedModel
5
+ from alexnet_model.configuration_alexnet import AlexNetConfig
6
+
7
+ class AlexNetPneumoniaClassification(PreTrainedModel):
8
+ config_class = AlexNetConfig
9
+
10
+ def __init__(self, config):
11
+ super(AlexNetPneumoniaClassification, self).__init__(config)
12
+ self.num_labels = config.num_labels
13
+ self.conv1 = nn.Conv2d(3, 96, kernel_size=11, stride=4, padding=0)
14
+ self.conv2 = nn.Conv2d(96, 256, kernel_size=5, stride=1,padding=2)
15
+ self.conv3 = nn.Conv2d(256, 384, kernel_size=3, stride=1, padding=1)
16
+ self.conv4 = nn.Conv2d(384, 384, kernel_size=3, stride=1, padding=1)
17
+ self.conv5 = nn.Conv2d(384, 256, kernel_size=3, stride=1, padding=1)
18
+ self.fc1 = nn.Linear(256*6*6, 4096)
19
+ self.fc2 = nn.Linear(4096, 4096)
20
+ self.fc3 = nn.Linear(4096, config.num_labels)
21
+
22
+ def forward(self, pixel_values, labels):
23
+ x = torch.relu(self.conv1(pixel_values))
24
+ x = torch.max_pool2d(x, kernel_size=3, stride=2, padding=0)
25
+ x = torch.relu(self.conv2(x))
26
+ x = torch.max_pool2d(x, kernel_size=3, stride=2, padding=0)
27
+ x = torch.relu(self.conv3(x))
28
+ x = torch.relu(self.conv4(x))
29
+ x = torch.relu(self.conv5(x))
30
+ x = torch.max_pool2d(x, kernel_size=3, stride=2, padding=0)
31
+ x = x.view(-1, 256*6*6)
32
+ x = torch.relu(self.fc1(x))
33
+ x = torch.relu(self.fc2(x))
34
+ logits = self.fc3(x)
35
+ loss = None
36
+ if labels is not None:
37
+ loss_fct = nn.CrossEntropyLoss()
38
+ loss = loss_fct(logits.view(-1, self.num_labels), labels)
39
+ return SequenceClassifierOutput(
40
+ loss=loss,
41
+ logits=logits,
42
+ )
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e9be1a6de4429e5d66c28503e4473695e3495b3c2e181d6edf6cf067c29587c7
3
  size 233163169
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f9a276565639298eb045525ddeed8cfcc4ae8e72a71a752038bb32554e294c9
3
  size 233163169
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0d18548ea342766d3c937d1dc717f196f8da5d287ca7dec4ba63c8c154a03fbe
3
  size 4091
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45e63e569777b2bca9c26e762d7f083e8beb099814be919fbb9f0d7b60b46bde
3
  size 4091