Integrating logic for setting up optimizers in run_train and config files (#33)

* added optimizers

* added optimizer logic for setting it up; todo-- fix optimizers and add step logic

* typing out the alphabet
This commit is contained in:
evonneng authored and GitHub committed 2022-04-21 13:23:18 -07:00
1 parent 4d1a6b2dbd
commit 17d837babf
7 files changed
+59 -24

No files matched your search

+6 -1
View File
@@ -3,9 +3,10 @@ The Graph module contains all trainable parameters.
"""
from abc import abstractmethod
from dataclasses import dataclass
from typing import Dict, Optional
from typing import Dict, List, Optional
from torch import nn
from torch.nn import Parameter
from torchtyping import TensorType
@@ -43,6 +44,10 @@ class Graph(nn.Module):
def populate_modules(self):
"""Initializes the modules that are part of the network."""
@abstractmethod
def get_param_groups(self) -> Dict[str, List[Parameter]]:
"""Returns the parameter groups of the network in a dictionary format"""
def get_in_dim(self, curr_node: Node) -> None:
"""Dynamically calculates and sets the input dimensions of the modules based on dependency graph
+13
View File
@@ -3,6 +3,8 @@ Implementation of vanilla nerf.
"""
from typing import Dict, List
from torch.nn import Parameter
from torchtyping import TensorType
from mattport.nerf.field.nerf import NeRFField
@@ -41,6 +43,17 @@ class NeRFGraph(Graph):
# losses
self.rgb_loss = MSELoss()
def get_param_groups(self) -> Dict[str, List[Parameter]]:
"""Obtain the parameter groups for the optimizers
Returns:
Dict[str, List[Parameter]]: Mapping of different parameter groups
"""
param_groups = {}
param_groups["camera"] = [dict(params=self.ray_generator.parameters())]
param_groups["graph"] = [dict(params=self.field_coarse.parameters()), dict(params=self.field_fine.parameters())]
return param_groups
def forward(self, ray_indices: TensorType["num_rays", 3]):
"""Takes in the ray indices and renders out values."""
# get the rays: