zaibutcooler commited on
Commit
384edc4
·
1 Parent(s): 83e9505

yume before training on gpu

Browse files
.github/workflows/hugging-face.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Unit Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - "main"
7
+ # TODO setup for huggingface space
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Setup Python
17
+ uses: actions/setup-python@v2
18
+ with:
19
+ python-version: 3.x
interface.py CHANGED
@@ -3,10 +3,11 @@ import torch
3
  from torchvision.utils import make_grid
4
  from torchvision.transforms import ToPILImage
5
 
 
6
  def main():
7
  st.title("Image Generation")
8
  st.write("Made with GANS from scratch")
9
-
10
-
11
- if __name__ == '__main__':
12
  main()
 
3
  from torchvision.utils import make_grid
4
  from torchvision.transforms import ToPILImage
5
 
6
+
7
  def main():
8
  st.title("Image Generation")
9
  st.write("Made with GANS from scratch")
10
+
11
+
12
+ if __name__ == "__main__":
13
  main()
sampler.py CHANGED
@@ -1,7 +1,7 @@
1
- from yume import Yume
2
 
3
  yume = Yume()
4
 
5
  yume.load_pretrained()
6
 
7
- yume.generate()
 
1
+ from .yume import Yume
2
 
3
  yume = Yume()
4
 
5
  yume.load_pretrained()
6
 
7
+ yume.generate()
tests/test_datasets.py CHANGED
@@ -1,7 +1,13 @@
1
  import unittest
2
 
 
3
  class TestDatasets(unittest.TestCase):
4
- pass
 
 
 
 
 
5
 
6
- if __name__ == '__main__':
7
- unittest.main()
 
1
  import unittest
2
 
3
+
4
  class TestDatasets(unittest.TestCase):
5
+ def test_download():
6
+ pass
7
+
8
+ def test_encode():
9
+ pass
10
+
11
 
12
+ if __name__ == "__main__":
13
+ unittest.main()
tests/test_demo.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # test_demo.py
2
+ import unittest
3
+
4
+
5
+ class TestDemoFunctions(unittest.TestCase):
6
+
7
+ def test_add_numbers(self):
8
+ self.assertEqual(add_numbers(2, 3), 5)
9
+ self.assertEqual(add_numbers(-1, 1), 0)
10
+ # Add more test cases as needed
11
+
12
+ def test_multiply_numbers(self):
13
+ self.assertEqual(multiply_numbers(2, 3), 6)
14
+ self.assertEqual(multiply_numbers(-1, 1), -1)
15
+ # Add more test cases as needed
16
+
17
+
18
+ if __name__ == "__main__":
19
+ unittest.main()
tests/test_pretrained.py CHANGED
@@ -1,11 +1,13 @@
1
  import unittest
2
 
 
3
  class TestPretrained(unittest.TestCase):
4
  def test_download():
5
  pass
6
-
7
  def test_generation():
8
  pass
9
 
10
- if __name__ == '__main__':
11
- unittest.main()
 
 
1
  import unittest
2
 
3
+
4
  class TestPretrained(unittest.TestCase):
5
  def test_download():
6
  pass
7
+
8
  def test_generation():
9
  pass
10
 
11
+
12
+ if __name__ == "__main__":
13
+ unittest.main()
tests/test_tokenizer.py CHANGED
@@ -1,15 +1,16 @@
1
  import unittest
2
 
 
3
  class TestTokenizer(unittest.TestCase):
4
  def test_encode():
5
  pass
6
-
7
  def test_decode():
8
  pass
9
-
10
  def test_equal_result():
11
  pass
12
-
13
-
14
- if __name__ == '__main__':
15
- unittest.main()
 
1
  import unittest
2
 
3
+
4
  class TestTokenizer(unittest.TestCase):
5
  def test_encode():
6
  pass
7
+
8
  def test_decode():
9
  pass
10
+
11
  def test_equal_result():
12
  pass
13
+
14
+
15
+ if __name__ == "__main__":
16
+ unittest.main()
tests/test_transformer.py CHANGED
@@ -1,12 +1,13 @@
1
  import unittest
2
 
 
3
  class TestTransformer(unittest.TestCase):
4
  def test_loading_model():
5
  pass
6
-
7
  def test_parameters():
8
  pass
9
-
10
 
11
- if __name__ == '__main__':
12
- unittest.main()
 
 
1
  import unittest
2
 
3
+
4
  class TestTransformer(unittest.TestCase):
5
  def test_loading_model():
6
  pass
7
+
8
  def test_parameters():
9
  pass
 
10
 
11
+
12
+ if __name__ == "__main__":
13
+ unittest.main()
training.py CHANGED
@@ -1,5 +1,5 @@
1
- from yume import Yume
2
 
3
  yume = Yume()
4
 
5
- yume.train()
 
1
+ from .yume import Yume
2
 
3
  yume = Yume()
4
 
5
+ yume.train()
version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "20231117"
 
1
+ __version__ = "20231117"
yume/config.py CHANGED
@@ -1,23 +1,20 @@
1
-
2
  class Config:
3
- def __init__(self,num_epoch:int,
4
- block_sized = 1024,
5
- vocab_sized = 50304,
6
- n_layer = 12,
7
- n_head = 12,
8
- n_embd = 768,
9
- dropout = 0.0,
10
- bias = True,
11
-
12
- ) -> None:
 
13
  self.num_epoch = num_epoch
14
  self.block_sized = 1024
15
- self.vocab_sized = 50304
16
  self.n_layerd = 12
17
  self.n_headd = 12
18
  self.n_embdd = 768
19
  self.dropout = 0.0
20
  self.bias = True
21
-
22
-
23
- config = Config()
 
 
1
  class Config:
2
+ def __init__(
3
+ self,
4
+ num_epoch: int,
5
+ block_sized=1024,
6
+ vocab_sized=50304,
7
+ n_layer=12,
8
+ n_head=12,
9
+ n_embd=768,
10
+ dropout=0.0,
11
+ bias=True,
12
+ ) -> None:
13
  self.num_epoch = num_epoch
14
  self.block_sized = 1024
15
+ self.vocab_sized = 50304
16
  self.n_layerd = 12
17
  self.n_headd = 12
18
  self.n_embdd = 768
19
  self.dropout = 0.0
20
  self.bias = True
 
 
 
yume/dataset.py CHANGED
@@ -1,5 +1,11 @@
1
  from datasets import load_dataset
2
 
 
 
3
  class Trainset:
4
  def __init__(self) -> None:
5
  pass
 
 
 
 
 
1
  from datasets import load_dataset
2
 
3
+
4
+ # TODO setup dataset
5
  class Trainset:
6
  def __init__(self) -> None:
7
  pass
8
+
9
+
10
+ def use_dataset(name=""):
11
+ pass
yume/models.py CHANGED
@@ -1,34 +1,49 @@
1
  import torch
2
  from torch import nn
3
  import torch.nn.functional as F
 
 
4
 
 
 
5
  class SelfAttention(nn.Module):
6
- def __init__(self, ) -> None:
7
  super().__init__()
8
-
9
- def forward(self):
10
  pass
11
 
 
12
  class MLP(nn.Module):
13
- def __init__(self, ) -> None:
14
  super().__init__()
15
-
16
- def forward(self):
17
  pass
18
 
 
19
  class Block(nn.Module):
20
- def __init__(self, ) -> None:
21
  super().__init__()
22
-
23
- def forward(self):
24
  pass
25
-
26
 
27
  class GPT(nn.Module):
28
- def __init__(self, config):
29
  super().__init__()
30
 
31
- self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
32
-
33
- def forward(x):
34
- pass
 
 
 
 
 
 
 
 
 
 
1
  import torch
2
  from torch import nn
3
  import torch.nn.functional as F
4
+ from .config import Config
5
+ from .utils import encode, decode
6
 
7
+
8
+ # TODO setup models
9
  class SelfAttention(nn.Module):
10
+ def __init__(self, config: Config) -> None:
11
  super().__init__()
12
+
13
+ def forward(self, x):
14
  pass
15
 
16
+
17
  class MLP(nn.Module):
18
+ def __init__(self, config: Config) -> None:
19
  super().__init__()
20
+
21
+ def forward(self, x):
22
  pass
23
 
24
+
25
  class Block(nn.Module):
26
+ def __init__(self, config: Config) -> None:
27
  super().__init__()
28
+
29
+ def forward(self, x):
30
  pass
31
+
32
 
33
  class GPT(nn.Module):
34
+ def __init__(self, config: Config):
35
  super().__init__()
36
 
37
+ self.device = "cuda" if torch.cuda.is_available() else "cpu"
38
+
39
+ def forward(self, x):
40
+ pass
41
+
42
+ def _init_weights(self):
43
+ pass
44
+
45
+ def configure_optimizer(self):
46
+ pass
47
+
48
+ def generate(self):
49
+ pass
yume/tokenizer.py CHANGED
@@ -1,5 +1,15 @@
 
1
  class Tokenizer:
2
  def __init__(self):
3
  pass
4
-
5
-
 
 
 
 
 
 
 
 
 
 
1
+ # TODO setup tokenizer
2
  class Tokenizer:
3
  def __init__(self):
4
  pass
5
+
6
+ def train(self):
7
+ pass
8
+
9
+ def encode(self, texts):
10
+ result = ""
11
+ return []
12
+
13
+ def decode(self, tensors):
14
+ result = ""
15
+ return tensors
yume/utils.py CHANGED
@@ -1,8 +1,18 @@
 
 
 
 
1
  def encode(text):
2
- pass
 
 
 
 
 
 
 
 
3
 
4
- def decode(text):
5
- pass
6
 
7
- def transform_data(data):
8
  pass
 
1
+ from .tokenizer import Tokenizer
2
+
3
+
4
+ # TODO setup utils
5
  def encode(text):
6
+ tokenizer = Tokenizer()
7
+ result = tokenizer.encode(text)
8
+ return result
9
+
10
+
11
+ def decode(tensor):
12
+ tokenizer = Tokenizer()
13
+ result = tokenizer.decode(tensor)
14
+ return result
15
 
 
 
16
 
17
+ def load_data(data):
18
  pass
yume/yume.py CHANGED
@@ -6,6 +6,7 @@ from .models import GPT
6
 
7
  config = Config()
8
 
 
9
  class Yume:
10
  def __init__(self, config):
11
  super().__init__()
@@ -18,4 +19,4 @@ class Yume:
18
  pass
19
 
20
  def generate(self):
21
- pass
 
6
 
7
  config = Config()
8
 
9
+
10
  class Yume:
11
  def __init__(self, config):
12
  super().__init__()
 
19
  pass
20
 
21
  def generate(self):
22
+ pass