repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/trainers/early_stoppers/base/early_stopper_base.py | src/trainers/early_stoppers/base/early_stopper_base.py | import logging
from utils.param_checking import check_exclusive
class EarlyStopperBase:
def __init__(
self,
every_n_epochs=None,
every_n_updates=None,
every_n_samples=None,
):
self.logger = logging.getLogger(type(self).__name__)
assert check_exc... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/trainers/early_stoppers/base/__init__.py | src/trainers/early_stoppers/base/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/trainers/eval/__init__.py | src/trainers/eval/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/trainers/eval/single_eval_trainer.py | src/trainers/eval/single_eval_trainer.py | import torch
import torch.nn as nn
from kappadata.wrappers import ModeWrapper
from trainers.base.sgd_trainer import SgdTrainer
class SingleEvalTrainer(SgdTrainer):
def __init__(
self,
max_epochs=0,
precision="float32",
effective_batch_size=2,
disable_gr... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/dummy_model.py | src/models/dummy_model.py | import numpy as np
import torch.nn as nn
from .base.single_model_base import SingleModelBase
class DummyModel(SingleModelBase):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.layer = nn.Linear(np.prod(self.input_shape), np.prod(self.output_shape or self.input_shape))
def forwa... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/__init__.py | src/models/__init__.py | import logging
from copy import deepcopy
from functools import partial
import torch.nn as nn
import yaml
from initializers import initializer_from_kwargs
from utils.factory import instantiate
def model_from_kwargs(kind=None, path_provider=None, data_container=None, **kwargs):
# exclude update_counter from copyi... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/cfd_hybrid_model.py | src/models/composite/cfd_hybrid_model.py | import torch
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class CfdHybridModel(CompositeModelBase):
def __init__(
self,
encoder,
latent,
decoder,
conditioner=None,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/rans_interpolated_model.py | src/models/composite/rans_interpolated_model.py | from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class RansInterpolatedModel(CompositeModelBase):
def __init__(
self,
latent,
decoder,
grid_resolution=None,
**kwargs,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/rans_gino_encdec_sdf_model.py | src/models/composite/rans_gino_encdec_sdf_model.py | from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class RansGinoEncdecSdfModel(CompositeModelBase):
def __init__(
self,
encoder,
latent,
decoder,
**kwargs,
):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/rans_simformer_nognn_sdf_model.py | src/models/composite/rans_simformer_nognn_sdf_model.py | import torch
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class RansSimformerNognnSdfModel(CompositeModelBase):
def __init__(
self,
grid_encoder,
mesh_encoder,
latent,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/rans_baseline_model.py | src/models/composite/rans_baseline_model.py | from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class RansBaselineModel(CompositeModelBase):
def __init__(
self,
latent,
decoder,
encoder=None,
**kwargs,
):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/cfd_simformer_model.py | src/models/composite/cfd_simformer_model.py | import einops
import torch
import torch.nn.functional as F
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
from utils.amp_utils import NoopContext
class CfdSimformerModel(CompositeModelBase):
def __init__(
self,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/__init__.py | src/models/composite/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/cfd_interpolated_model.py | src/models/composite/cfd_interpolated_model.py | import scipy
import einops
import torch
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class CfdInterpolatedModel(CompositeModelBase):
def __init__(
self,
latent,
decoder,
condit... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/cfd_baseline_model.py | src/models/composite/cfd_baseline_model.py | import torch
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class CfdBaselineModel(CompositeModelBase):
def __init__(
self,
encoder,
latent,
decoder,
conditioner=None... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/lagrangian_simformer_model.py | src/models/composite/lagrangian_simformer_model.py | import einops
import torch
import torch.nn.functional as F
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class LagrangianSimformerModel(CompositeModelBase):
def __init__(
self,
encoder,
lat... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/cfd_simformer_efficient_reconstruct_model.py | src/models/composite/cfd_simformer_efficient_reconstruct_model.py | import einops
import torch
import torch.nn.functional as F
from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class CfdSimformerEfficientReconstructModel(CompositeModelBase):
def __init__(
self,
encoder,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/composite/rans_simformer_nognn_model.py | src/models/composite/rans_simformer_nognn_model.py | from models import model_from_kwargs
from models.base.composite_model_base import CompositeModelBase
from utils.factory import create
class RansSimformerNognnModel(CompositeModelBase):
def __init__(
self,
encoder,
latent,
decoder,
**kwargs,
):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/base/single_model_base.py | src/models/base/single_model_base.py | import torch
from freezers import freezer_from_kwargs
from initializers.functional import ALL_BATCHNORMS
from optimizers import optim_ctor_from_kwargs
from utils.factory import create, create_collection
from utils.model_utils import get_trainable_param_count
from .model_base import ModelBase
class SingleModelBase(Mo... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/base/composite_model_base.py | src/models/base/composite_model_base.py | import torch
from .model_base import ModelBase
from .single_model_base import SingleModelBase
class CompositeModelBase(ModelBase):
def forward(self, *args, **kwargs):
""" all computations for training have to be within the forward method (otherwise DDP doesn't sync grads) """
raise NotImplemented... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/base/model_base.py | src/models/base/model_base.py | import logging
import torch.nn
from initializers import initializer_from_kwargs
from providers.path_provider import PathProvider
from utils.factory import create_collection
from utils.naming_util import snake_type_name
from utils.data_container import DataContainer
class ModelBase(torch.nn.Module):
def __init__... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/base/__init__.py | src/models/base/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/fno_gino_model.py | src/models/latent/fno_gino_model.py | import einops
from kappamodules.layers import LinearProjection
from kappautils.param_checking import to_ntuple
from neuralop.models import FNO
from models.base.single_model_base import SingleModelBase
class FnoGinoModel(SingleModelBase):
""" FNO model from GINO """
def __init__(
self,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/fno_cond_model.py | src/models/latent/fno_cond_model.py | from functools import partial
import einops
from models.base.single_model_base import SingleModelBase
from modules.pdearena.conditional_twod_resnet import ResNet, FourierBasicBlock
class FnoCondModel(SingleModelBase):
""" FNO model from PDEArena with conditioning """
def __init__(self, dim, modes, depth=4,... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/transformer_model.py | src/models/latent/transformer_model.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import DitBlock, PrenormBlock
from torch import nn
from models.base.single_model_base import SingleModelBase
class TransformerModel(SingleModelBase):
def __init__(
self,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/unet_gino_model.py | src/models/latent/unet_gino_model.py | import einops
from kappamodules.layers import LinearProjection
from kappautils.param_checking import to_ntuple
from kappamodules.unet import UnetGino
from models.base.single_model_base import SingleModelBase
class UnetGinoModel(SingleModelBase):
""" Unet model from GINO """
def __init__(self, dim, depth=4, ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/unet_pdearena_model.py | src/models/latent/unet_pdearena_model.py | import einops
from kappamodules.unet import UnetPdearena
from models.base.single_model_base import SingleModelBase
class UnetPdearenaModel(SingleModelBase):
def __init__(self, dim, **kwargs):
super().__init__(**kwargs)
self.dim = dim
# propagate output shape
seqlen, input_dim = s... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/unet_denoising_diffusion_model.py | src/models/latent/unet_denoising_diffusion_model.py | import einops
from kappamodules.unet import UnetDenoisingDiffusion
from models.base.single_model_base import SingleModelBase
class UnetDenoisingDiffusionModel(SingleModelBase):
def __init__(self, dim, depth, num_attn_heads=None, **kwargs):
super().__init__(**kwargs)
self.dim = dim
self.de... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/latent/__init__.py | src/models/latent/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/cfd_pool_transformer_perceiver.py | src/models/encoders/cfd_pool_transformer_perceiver.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock, DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.single_model_base import Singl... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/cfd_gino.py | src/models/encoders/cfd_gino.py | import numpy as np
from models.base.single_model_base import SingleModelBase
from modules.gno.cfd_gino_mesh_to_grid import CfdGinoMeshToGrid
class CfdGino(SingleModelBase):
def __init__(self, dim, **kwargs):
super().__init__(**kwargs)
self.dim = dim
self.resolution = self.data_container.g... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/cfd_interpolate.py | src/models/encoders/cfd_interpolate.py | import einops
import numpy as np
from torch import nn
from models.base.single_model_base import SingleModelBase
from modules.gno.cfd_interpolate_mesh_to_grid import CfdInterpolateMeshToGrid
class CfdInterpolate(SingleModelBase):
def __init__(self, dim, **kwargs):
super().__init__(**kwargs)
self.d... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/lagrangian_perceiver.py | src/models/encoders/lagrangian_perceiver.py | import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed
from kappamodules.transformer import PerceiverPoolingBlock, Mlp
from torch_geometric.utils import to_dense_batch
from models.base.single_model_base import SingleModelBase
from optimizers.param_group_modifiers.exclude_from_wd_by_name_modif... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_gino.py | src/models/encoders/rans_gino.py | import numpy as np
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_mesh_to_grid import RansGinoMeshToGrid
class RansGino(SingleModelBase):
def __init__(self, dim, **kwargs):
super().__init__(**kwargs)
self.dim = dim
self.resolution = self.data_containe... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_grid_simple_cnn.py | src/models/encoders/rans_grid_simple_cnn.py | import einops
import torch
from torch import nn
from models.base.single_model_base import SingleModelBase
from optimizers.param_group_modifiers.exclude_from_wd_by_name_modifier import ExcludeFromWdByNameModifier
class RansGridSimpleCnn(SingleModelBase):
def __init__(
self,
dim,
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_gnn_transformer_perceiver.py | src/models/encoders/rans_gnn_transformer_perceiver.py | import torch
from functools import partial
import einops
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock
from kappamodules.vit import DitBlock
from torch import nn
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/lagrangian_pool_transformer_perceiver.py | src/models/encoders/lagrangian_pool_transformer_perceiver.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.si... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_sdf.py | src/models/encoders/rans_sdf.py | import numpy as np
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_mesh_to_grid_sdf import RansGinoMeshToGridSdf
from kappamodules.layers import ContinuousSincosEmbed
from torch import nn
from kappamodules.layers.continuous_sincos_embed import ContinuousSincosEmbed
class RansSdf(S... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/lagrangian_gnn_pool_transformer_perceiver.py | src/models/encoders/lagrangian_gnn_pool_transformer_perceiver.py | from functools import partial
import einops
import torch
from kappamodules.init import init_xavier_uniform_zero_bias
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock
from kappamodules.layers import LinearProjection
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_hierarchical_perceiver.py | src/models/encoders/rans_hierarchical_perceiver.py | from functools import partial
import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock
from kappamodules.vit import DitBlock
from kappautils.param_checking import to_ntuple
from torch import nn
from torch... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_perceiver.py | src/models/encoders/rans_perceiver.py | import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed
from kappamodules.transformer import PerceiverPoolingBlock, Mlp
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.single_model_base import SingleModelBase
from optimizers.param_group_modifiers.exclude_... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/cfd_gnn_pool_transformer_perceiver.py | src/models/encoders/cfd_gnn_pool_transformer_perceiver.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.si... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_gino_sdf.py | src/models/encoders/rans_gino_sdf.py | import numpy as np
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_mesh_to_grid_sdf import RansGinoMeshToGridSdf
from kappamodules.layers import ContinuousSincosEmbed
from torch import nn
class RansGinoSdf(SingleModelBase):
def __init__(self, dim, resolution=None, **kwargs):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/__init__.py | src/models/encoders/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_pool_transformer.py | src/models/encoders/rans_pool_transformer.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.si... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/cfd_pool_transformer.py | src/models/encoders/cfd_pool_transformer.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.si... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_grid_convnext.py | src/models/encoders/rans_grid_convnext.py | import numpy as np
import einops
import torch
from kappamodules.convolution import ConvNext
from torch import nn
import torch.nn.functional as F
from models.base.single_model_base import SingleModelBase
from optimizers.param_group_modifiers.exclude_from_wd_by_name_modifier import ExcludeFromWdByNameModifier
class Ran... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_pool_transformer_perceiver.py | src/models/encoders/rans_pool_transformer_perceiver.py | from functools import partial
import torch
from kappamodules.layers import LinearProjection
from kappamodules.transformer import PerceiverPoolingBlock, PrenormBlock, DitPerceiverPoolingBlock
from kappamodules.vit import DitBlock
from torch import nn
from torch_geometric.utils import to_dense_batch
from models.base.si... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_grid_unet.py | src/models/encoders/rans_grid_unet.py | import einops
import torch
from torch import nn
from models.base.single_model_base import SingleModelBase
from optimizers.param_group_modifiers.exclude_from_wd_by_name_modifier import ExcludeFromWdByNameModifier
from kappamodules.vit import VitPatchEmbed, VitPosEmbed
from kappamodules.transformer import PerceiverPooli... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/encoders/rans_gino_sdf_og.py | src/models/encoders/rans_gino_sdf_og.py | import numpy as np
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_mesh_to_grid_sdf_og import RansGinoMeshToGridSdfOg
from kappamodules.layers import ContinuousSincosEmbed
from torch import nn
class RansGinoSdfOg(SingleModelBase):
def __init__(self, hidden_dim, output_dim, **k... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/conditioners/timestep_velocity_conditioner_pdearena.py | src/models/conditioners/timestep_velocity_conditioner_pdearena.py | from kappamodules.functional.pos_embed import get_sincos_1d_from_seqlen
from kappamodules.init import init_xavier_uniform_zero_bias, init_truncnormal_zero_bias
from kappamodules.layers import ContinuousSincosEmbed
from torch import nn
from models.base.single_model_base import SingleModelBase
class TimestepVelocityCo... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/conditioners/__init__.py | src/models/conditioners/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/conditioners/timestep_conditioner_pdearena.py | src/models/conditioners/timestep_conditioner_pdearena.py | from kappamodules.functional.pos_embed import get_sincos_1d_from_seqlen
from kappamodules.init import init_xavier_uniform_zero_bias
from kappamodules.layers import ContinuousSincosEmbed
from torch import nn
from models.base.single_model_base import SingleModelBase
class TimestepConditionerPdearena(SingleModelBase):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/generic_extractor.py | src/models/extractors/generic_extractor.py | from torch import nn
from .base.extractor_base import ExtractorBase
from .base.forward_hook import ForwardHook
class GenericExtractor(ExtractorBase):
def to_string(self):
return f"GenericExtractor({self.model_path})"
def _get_own_outputs(self):
return {self.model_path: self.outputs[self.mode... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/__init__.py | src/models/extractors/__init__.py | from utils.factory import instantiate
def extractor_from_kwargs(kind, **kwargs):
return instantiate(module_names=[f"models.extractors.{kind}"], type_names=[kind], **kwargs)
| python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/base/forward_hook.py | src/models/extractors/base/forward_hook.py | class StopForwardException(Exception):
pass
class ForwardHook:
def __init__(
self,
outputs: dict,
output_name: str,
raise_exception: bool = False,
):
self.outputs = outputs
self.output_name = output_name
self.raise_exception = raise_e... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/base/extractor_base.py | src/models/extractors/base/extractor_base.py | from models.extractors.finalizers import finalizer_from_kwargs
from models.extractors.finalizers.concat_finalizer import ConcatFinalizer
from utils.factory import create
from utils.select_with_path import select_with_path
class ExtractorBase:
def __init__(
self,
pooling=None,
r... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/base/__init__.py | src/models/extractors/base/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/base/without_extractor_hooks.py | src/models/extractors/base/without_extractor_hooks.py | from contextlib import contextmanager
from models.extractors.base.forward_hook import StopForwardException
@contextmanager
def without_extractor_hooks(extractors):
assert isinstance(extractors, (tuple, list))
for pooling in extractors:
pooling.disable_hooks()
try:
yield
except StopFor... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/finalizers/__init__.py | src/models/extractors/finalizers/__init__.py | from utils.factory import instantiate
def finalizer_from_kwargs(kind, **kwargs):
return instantiate(module_names=[f"models.extractors.finalizers.{kind}"], type_names=[kind], **kwargs)
| python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/extractors/finalizers/concat_finalizer.py | src/models/extractors/finalizers/concat_finalizer.py | import torch
class ConcatFinalizer:
def __init__(self, dim=None):
self.dim = dim
def __call__(self, features):
if self.dim is None:
assert len(features) == 1
return features[0]
return torch.concat(features, dim=self.dim)
def __repr__(self):
return ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/cfd_gino.py | src/models/decoders/cfd_gino.py | import numpy as np
import torch
from models.base.single_model_base import SingleModelBase
from modules.gno.cfd_gino_grid_to_mesh import CfdGinoGridToMesh
class CfdGino(SingleModelBase):
def __init__(self, hidden_dim, clamp=None, clamp_mode="log", **kwargs):
super().__init__(**kwargs)
self.clamp =... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/cfd_interpolate.py | src/models/decoders/cfd_interpolate.py | import einops
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from models.base.single_model_base import SingleModelBase
from modules.gno.cfd_interpolate_grid_to_mesh import CfdInterpolateGridToMesh
class CfdInterpolate(SingleModelBase):
def __init__(self, dim=None, clamp=None,... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/rans_interpolated.py | src/models/decoders/rans_interpolated.py | import einops
import torch
import torch.nn.functional as F
from torch import nn
from models.base.single_model_base import SingleModelBase
class RansInterpolated(SingleModelBase):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# input_shape is (None, input_dim)
_, input_dim = se... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/lagrangian_perceiver.py | src/models/decoders/lagrangian_perceiver.py | from functools import partial
import einops
import torch
from kappamodules.init import init_xavier_uniform_zero_bias
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, DitPerceiverBlock
from torch import nn
from torch_geometric.utils import unba... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/rans_gino.py | src/models/decoders/rans_gino.py | from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_grid_to_mesh import RansGinoGridToMesh
class RansGino(SingleModelBase):
def __init__(self, dim, **kwargs):
super().__init__(**kwargs)
# input_shape is (None, input_dim)
_, input_dim = self.input_shape
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/lagrangian_transformer_perceiver.py | src/models/decoders/lagrangian_transformer_perceiver.py | from functools import partial
import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, DitPerceiverBlock
from kappamodules.vit import DitBlock, VitBlock
from torch import nn
from torch_geometric.utils import unbatch
from mo... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/cfd_transformer_perceiver.py | src/models/decoders/cfd_transformer_perceiver.py | from functools import partial
import einops
import numpy as np
import torch
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, DitPerceiverBlock, DitBlock
from kappamodules.vit import VitBlock
from torch import nn
from torch_geometric.utils impo... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/rans_gino_latent.py | src/models/decoders/rans_gino_latent.py | import einops
from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_latent_to_mesh import RansGinoLatentToMesh
class RansGinoLatent(SingleModelBase):
def __init__(self, hidden_dim, bottleneck_dim=None, pred_hidden_dim=None, **kwargs):
super().__init__(**kwargs)
# in... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/rans_perceiver.py | src/models/decoders/rans_perceiver.py | import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, Mlp
from torch_geometric.utils import unbatch
from torch import nn
from models.base.single_model_base import SingleModelBase
class RansPerceiver(SingleModelBase):
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/__init__.py | src/models/decoders/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/rans_gino_og.py | src/models/decoders/rans_gino_og.py | from models.base.single_model_base import SingleModelBase
from modules.gno.rans_gino_grid_to_mesh_og import RansGinoGridToMeshOg
class RansGinoOg(SingleModelBase):
def __init__(self, hidden_dim, bottleneck_dim, **kwargs):
super().__init__(**kwargs)
# input_shape is (None, input_dim)
_, inp... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/cfd_perceiver.py | src/models/decoders/cfd_perceiver.py | from functools import partial
import einops
import torch
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, DitPerceiverBlock
from torch import nn
from torch_geometric.utils import unbatch
from models.base.single_model_base import SingleModelBa... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/models/decoders/lagrangian_perceiver_gaussian_sincos_pos.py | src/models/decoders/lagrangian_perceiver_gaussian_sincos_pos.py | from functools import partial
import einops
import torch
from kappamodules.init import init_xavier_uniform_zero_bias
from kappamodules.layers import ContinuousSincosEmbed, LinearProjection
from kappamodules.transformer import PerceiverBlock, DitPerceiverBlock
from torch import nn
from torch_geometric.utils import unba... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/run.py | src/distributed/run.py | import logging
import os
import platform
import psutil
import torch
import yaml
from torch.distributed import init_process_group, destroy_process_group, barrier
from torch.multiprocessing import spawn
from .config import (
is_managed,
get_world_size_from_env,
get_rank_from_env,
get_local_rank,
is_... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/gather.py | src/distributed/gather.py | import einops
import torch
import torch.distributed as dist
from .config import is_distributed, get_world_size
from .functional.all_gather_grad_autograd import AllGatherGradAutograd
from .functional.all_gather_grad_overwrite import AllGatherGradOverwrite
def get_device_and_bfloat16supported():
# gloo cpu -> okay... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/config.py | src/distributed/config.py | import logging
import os
import torch.distributed as dist
def is_slurm_run():
if os.environ.get("SLURM_JOB_NAME", None) == "interactive":
return False
return "SLURM_PROCID" in os.environ and "SLURM_NTASKS_PER_NODE" in os.environ
def is_mpi_managed_run():
return (
"OMPI_COMM_WORLD_SI... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/__init__.py | src/distributed/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/functional/all_gather_grad_overwrite.py | src/distributed/functional/all_gather_grad_overwrite.py | import torch
import torch.distributed as dist
# https://discuss.pytorch.org/t/dist-all-gather-and-gradient-preservation-in-multi-gpu-training/120696/2
class AllGatherGradOverwrite:
@staticmethod
def apply(x):
output = [torch.zeros_like(x) for _ in range(dist.get_world_size())]
dist.all_gather(... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/functional/all_gather_grad_autograd.py | src/distributed/functional/all_gather_grad_autograd.py | import torch
import torch.distributed as dist
# noinspection PyAbstractClass
class AllGatherGradAutograd(torch.autograd.Function):
"""
Gathers tensors from all process and supports backward propagation
for the gradients across processes.
"""
# noinspection PyMethodOverriding
@staticmethod
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/distributed/functional/__init__.py | src/distributed/functional/__init__.py | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false | |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/object_from_kwargs.py | src/utils/object_from_kwargs.py | def objects_from_kwargs(kwargs):
if kwargs is None:
return {}
result = {}
for k, v in kwargs.items():
if isinstance(v, dict):
# if no factory type is supplied -> derive from key
# e.g. mask generators are usually unique and defined via the "mask_generator" key
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/collator_from_kwargs.py | src/utils/collator_from_kwargs.py | from utils.factory import instantiate
def collator_from_kwargs(kind, **kwargs):
return instantiate(
module_names=[
f"datasets.collators.{kind}",
f"kappadata.collators.{kind}",
],
type_names=[kind],
**kwargs,
)
| python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/num_worker_heuristic.py | src/utils/num_worker_heuristic.py | import logging
import os
from distributed.config import is_slurm_run
def get_fair_cpu_count():
total_cpu_count = get_total_cpu_count()
if total_cpu_count == 0:
return 0
device_count = _get_device_count()
# divide cpus among devices
if is_slurm_run():
# slurm already divides cpus ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/env_utils.py | src/utils/env_utils.py | import os
def env_flag_is_true(key):
if key not in os.environ:
return False
return os.environ[key] in ["true", "True", "T"]
| python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/amp_utils.py | src/utils/amp_utils.py | import logging
import torch
from torch.cuda.amp import GradScaler
FLOAT32_ALIASES = ["float32", 32]
FLOAT16_ALIASES = ["float16", 16]
BFLOAT16_ALIASES = ["bfloat16", "bf16"]
VALID_PRECISIONS = FLOAT32_ALIASES + FLOAT16_ALIASES + BFLOAT16_ALIASES
def get_supported_precision(desired_precision, device, backup_precisio... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/png_utils.py | src/utils/png_utils.py | import einops
import numpy as np
import png
import torch
from PIL import Image
from torchvision.transforms.functional import to_tensor, to_pil_image
VIRIDIS_PALETTE = [
68, 1, 84,
68, 2, 86,
69, 4, 87,
69, 5, 89,
70, 7, 90,
70, 8, 92,
70, 10, 93,
70, 11, 94,
71, 13, 96,
71, 14, ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/loss_utils.py | src/utils/loss_utils.py | import torch
def apply_reduction(tensor, reduction="mean"):
if tensor.dtype == torch.bool:
tensor = tensor.float()
if reduction == "mean":
return tensor.mean()
if reduction == "mean_per_sample":
if tensor.ndim > 1:
return tensor.flatten(start_dim=1).mean(dim=1)
... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/system_info.py | src/utils/system_info.py | import logging
import os
import platform
import shlex
import sys
from pathlib import Path
from distributed.config import get_rank, get_local_rank
from utils.logging_util import log_from_all_ranks
from utils.num_worker_heuristic import get_total_cpu_count
def get_cli_command():
# print the command with which the ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/data_container.py | src/utils/data_container.py | import logging
import kappadata as kd
import torch
from kappadata.collators import KDComposeCollator, KDSingleCollatorWrapper
from kappadata.samplers import (
RandomSampler,
DistributedSampler,
SemiSampler,
SequentialSampler,
WeightedSampler,
ClassBalancedSampler,
)
from kappadata.wrappers impo... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/logging_util.py | src/utils/logging_util.py | import logging
import sys
from collections import defaultdict
from contextlib import contextmanager
from distributed.config import is_rank0
def _add_handler(handler, prefix=""):
logger = logging.getLogger()
if prefix != "":
prefix = f"{prefix} "
handler.setFormatter(logging.Formatter(
fmt... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/noop_tqdm.py | src/utils/noop_tqdm.py | class NoopTqdm:
def __init__(self, iterable):
self.iterable = iterable
def __enter__(self):
return self
def __exit__(self, *_, **__):
pass
def noop(self, *_, **__):
pass
def __getattr__(self, item):
return self.noop
def __iter__(self):
yield f... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/wandb_utils.py | src/utils/wandb_utils.py | import logging
import os
import platform
from copy import deepcopy
import torch
import wandb
from configs.wandb_config import WandbConfig
from distributed.config import is_rank0, get_world_size, get_nodes
from providers.config_providers.noop_config_provider import NoopConfigProvider
from providers.config_providers.pr... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/naming_util.py | src/utils/naming_util.py | from kappadata.datasets import KDSubset
def join_names(name1, name2):
if name1 is None:
return name2
assert name2 is not None
return f"{name1}.{name2}"
def pascal_to_snake(pascal_case: str) -> str:
"""
convert pascal/camel to snake case https://learn.microsoft.com/en-us/visualstudio/code... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/cumsum.py | src/utils/cumsum.py | def cumsum_of_sequence(sequence):
r, s = [], 0
for e in sequence:
l = len(e)
r.append(l + s)
s += l
return r
| python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/functional.py | src/utils/functional.py | import einops
import numpy as np
import torch
import torch.nn.functional as F
def get_powers_of_two(min_value, max_value):
powers_of_two = []
if max_value > 0:
powers_of_two += [2 ** i for i in range(int(np.log2(max_value)) + 1)]
return [p for p in powers_of_two if p >= min_value]
def is_power_o... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/schedule_utils.py | src/utils/schedule_utils.py | def get_value_or_default(default, schedule=None, update_counter=None):
if schedule is not None:
assert update_counter is not None
return schedule.get_value(
step=update_counter.cur_checkpoint.update,
total_steps=update_counter.end_checkpoint.update,
)
return defau... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/bidict.py | src/utils/bidict.py | class Bidict:
def __init__(self, forward=None, backward=None):
assert forward is None or backward is None
self._forward = {}
self._backward = {}
if forward is not None:
for key, value in forward.items():
self.set_forward(key, value)
if backward is ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/param_checking.py | src/utils/param_checking.py | import collections.abc
from itertools import repeat
from pathlib import Path
# adapted from timm (timm/models/layers/helpers.py)
def _ntuple(n):
def parse(x):
if isinstance(x, collections.abc.Iterable):
assert len(x) == n
return x
return tuple(repeat(x, n))
return pars... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
ml-jku/UPT | https://github.com/ml-jku/UPT/blob/f148ef187973ef4958e8a5324c6692dd2582ad97/src/utils/seed.py | src/utils/seed.py | import logging
import random
from contextlib import ContextDecorator
import numpy as np
import torch
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
logging.info(f"set seed to {seed}")
def ... | python | MIT | f148ef187973ef4958e8a5324c6692dd2582ad97 | 2026-01-05T07:12:15.158856Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.