|
import torch |
|
import torch.nn as nn |
|
from huggingface_hub import PyTorchModelHubMixin |
|
|
|
|
|
class MyModel( |
|
nn.Module, |
|
PyTorchModelHubMixin, |
|
|
|
repo_url="https://huggingface.co/Robzy/random-genre", |
|
pipeline_tag="audio-classification", |
|
license="mit", |
|
): |
|
def __init__(self, num_channels: int, hidden_size: int, num_classes: int): |
|
super().__init__() |
|
self.param = nn.Parameter(torch.rand(num_channels, hidden_size)) |
|
self.linear = nn.Linear(hidden_size, num_classes) |
|
|
|
def forward(self, x): |
|
return self.linear(x + self.param) |
|
|
|
|
|
config = {"num_channels": 3, "hidden_size": 32, "num_classes": 10} |
|
model = MyModel(**config) |
|
|
|
|
|
|
|
|
|
model.push_to_hub("Robzy/random-genre") |