some initial module structuring

This commit is contained in:
Ethan Weber committed 2022-04-08 17:01:47 +00:00
1 parent 8a53684131
commit 91f57726ae
7 files changed
+67 -18

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
{
"PositionalEncoder": {
"name": "encoder_0",
"inputs": [
"x"
],
"meta_data": {
"output_dim": 8
}
},
"MLP": {
"name": "mlp_0",
"inputs": [
"encoder_0", "encoder_0"
],
"meta_data": {
"num_layers": 8,
"num_skip_connections": [
3,
7
],
"hidden_dim": 256,
"output_dim": 8
}
},
"RGB": {
"name": "rgb_0",
"inputs": ["mlp_0"]
},
"Density": {
"name": "rgb_1",
"inputs": ["mlp_0"]
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ Builds the dataset
import importlib
import logging
from mattport.nerf.dataset.base import Dataset
from mattport.nerf.dataset.dataset import Dataset
def build_dataset(config: dict) -> Dataset:
File renamed without changes.
+25 -4
View File
@@ -3,7 +3,7 @@ The Graph module contains all trainable parameters.
"""
from dataclasses import dataclass
from torch import nn
from mattport.nerf.modules.positional_encoder import PositionalEncoder
@dataclass
class GraphInputs:
@@ -19,10 +19,31 @@ class Graph(nn.Module):
nn (_type_): _description_
"""
def __init__(self) -> None:
def __init__(self, modules_config: dict) -> None:
super().__init__()
# # for key in ...
# temp = graph_config.positional_encoder
# PositionalEncoder(name=temp.name, name=temp.inputs, )
# self.modules = {}
# self.modules["name"] = MLP()
self.modules = {}
self.encoder_0 = Encoder()
self.mlp_0 = MLP()
raise NotImplementedError
def forward(self):
def forward(self, x):
"""_summary_"""
raise NotImplementedError
# raise NotImplementedError
for name in queue: # "encoder_0",
# assert name.output is not None
x = self.modules[name](x)
# self.mlp_0
@@ -8,6 +8,10 @@ from torchtyping import TensorType
class Encoding(nn.Module):
"""Encode an input tensor. Intended to be subclassed"""
def __init__(self, name: str, inputs: list, meta_data: dict) -> None:
super().__init__()
raise NotImplementedError
def encode(self, in_tensor: TensorType[..., "input_dim"]) -> TensorType[..., "output_dim"]:
"""Encodes an input tensor.
@@ -1,10 +1,4 @@
"""
Collection of Models
"""
from typing import Optional
from torch import nn
from torchtyping import TensorType
class MLP(nn.Module):
@@ -30,7 +24,6 @@ class MLP(nn.Module):
out_activation (Optional[nn.Module], optional): output activation function. Defaults to None.
"""
super().__init__()
layers = []
for i in range(num_layers):
if i == 0:
+3 -6
View File
@@ -17,19 +17,16 @@ class Trainer(object):
self.optimizer = None
def setup_dataset(self):
"""_summary_
"""
"""_summary_"""
self.train_dataset = build_dataset(self.config.dataset)
self.test_dataset = build_dataset(self.config.dataset)
def setup_graph(self):
"""_summary_
"""
"""_summary_"""
self.graph = Graph()
def setup_optimizer(self):
"""_summary_
"""
"""_summary_"""
self.optimizer = Optimizer(params=self.graph.parameters(), **self.config.optimizer)
def load_checkpoint(self):