flavioschneider commited on
Commit
9f73bcc
·
1 Parent(s): 0d8c061

Upload AutoEncoder1d

Browse files
Files changed (3) hide show
  1. autoencoder.py +31 -0
  2. config.json +6 -1
  3. pytorch_model.bin +3 -0
autoencoder.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PreTrainedModel
2
+ from audio_encoders_pytorch import AutoEncoder1d as AE1d, TanhBottleneck
3
+ from .autoencoder_config import AutoEncoder1dConfig
4
+
5
+ bottleneck = { 'tanh': TanhBottleneck }
6
+
7
+ class AutoEncoder1d(PreTrainedModel):
8
+
9
+ config_class = AutoEncoder1dConfig
10
+
11
+ def __init__(self, config: AutoEncoder1dConfig):
12
+ super().__init__(config)
13
+
14
+ self.autoencoder = AE1d(
15
+ in_channels = config.in_channels,
16
+ patch_size = config.patch_size,
17
+ channels = config.channels,
18
+ multipliers = config.multipliers,
19
+ factors = config.factors,
20
+ num_blocks = config.num_blocks,
21
+ bottleneck = bottleneck[config.bottleneck]()
22
+ )
23
+
24
+ def forward(self, *args, **kwargs):
25
+ return self.autoencoder(*args, **kwargs)
26
+
27
+ def encode(self, *args, **kwargs):
28
+ return self.autoencoder.encode(*args, **kwargs)
29
+
30
+ def decode(self, *args, **kwargs):
31
+ return self.autoencoder.decode(*args, **kwargs)
config.json CHANGED
@@ -1,6 +1,10 @@
1
  {
 
 
 
2
  "auto_map": {
3
- "AutoConfig": "autoencoder_config.AutoEncoder1dConfig"
 
4
  },
5
  "bottleneck": "tanh",
6
  "channels": 32,
@@ -32,5 +36,6 @@
32
  8
33
  ],
34
  "patch_size": 4,
 
35
  "transformers_version": "4.24.0"
36
  }
 
1
  {
2
+ "architectures": [
3
+ "AutoEncoder1d"
4
+ ],
5
  "auto_map": {
6
+ "AutoConfig": "autoencoder_config.AutoEncoder1dConfig",
7
+ "AutoModel": "autoencoder.AutoEncoder1d"
8
  },
9
  "bottleneck": "tanh",
10
  "channels": 32,
 
36
  8
37
  ],
38
  "patch_size": 4,
39
+ "torch_dtype": "float32",
40
  "transformers_version": "4.24.0"
41
  }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f5038eca135d02345e04b3ce8b44a2e66e709e5d0a0ebb8f2209349d3087ee6
3
+ size 83290921