This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BSD 3-Clause License | |
# | |
# Copyright (c) 2023, maharjun | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright notice, this | |
# list of conditions and the following disclaimer. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A bunch of utilities that prove useful with the SCOOP Parallelization framework""" | |
############################################################################### | |
# BSD 3-Clause License | |
# | |
# Copyright (c) 2023, maharjun | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This file contains the code for some very helpful utilities to store data and | |
perform auxiliary actions periodically in training loops and the like. | |
""" | |
############################################################################### | |
# BSD 3-Clause License | |
# | |
# Copyright (c) 2023, maharjun | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This module provides utilities for caching the results of time-consuming functions | |
to disk for faster retrieval in future runs. The main classes and functions are: | |
- hash_det: A function that generates a deterministic hash value for an object | |
(immune to changes in its id). | |
- function_takes_no_arguments: A helper function that checks if a given function | |
takes no arguments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a shim for dill to be used with torch (namely that when used in a project | |
that pickles torch objects, dill should be imported from this module). | |
for example:: | |
from utils.dillshim import dill | |
The purpose of this shim is register the pickling and unpickling logic | |
for certain native pytorch types such as torch random generators that | |
otherwise cannot be pickled by dill, as well as to be able to unpickle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Utility functions for PyTorch data manipulation and device handling. | |
This module provides various utility functions for handling PyTorch datasets, tensors, and devices. Functions include: | |
- Splitting datasets into train and test sets | |
- Concatenating multiple datasets | |
- Generating random batches from a dataset | |
- Converting data to a specific device | |
- Retrieving the default device | |
- Getting GPU device names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The cached_class_method utility is a Python function decorator that caches the | |
results of a class method in order to avoid recomputing the same values when the | |
method is called multiple times with the same arguments. It does so by storing the | |
results in a cache dictionary as an attribute of the class instance, and looking | |
them up whenever the method is called with the same arguments. | |
""" | |
############################################################################### | |
# BSD 3-Clause License |