Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def free_cuda_memory(): | |
import gc | |
gc.collect() | |
torch.cuda.empty_cache() |
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
def set_random_seeds(seed_value=555, device='cuda:0'): | |
'''source https://forums.fast.ai/t/solved-reproducibility-where-is-the-randomness-coming-in/31628/5.''' | |
np.random.seed(seed_value) | |
torch.manual_seed(seed_value) | |
random.seed(seed_value) | |
if device != 'cpu': | |
torch.cuda.manual_seed(seed_value) | |
torch.cuda.manual_seed_all(seed_value) | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False |
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
class ShapyLinear(nn.Module): | |
"""Can model any affine function from the set of tensors of any (fixed) shape `in_shape` to | |
the set of tensors of any (fixed) shape `out_shape`. | |
In forward method the first modes of `inputs` are interpreted as indices of samples, | |
then come the modes corresponding to `in_shape`. The affine function is applied to each sample.""" | |
def __init__(self, in_shape, out_shape): | |
""":param in_shape: shape of one input sample | |
:param out_shape: shape of one output sample""" | |
super().__init__() |
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
# https://about.sourcegraph.com/blog/thyme-a-simple-cli-to-measure-human-time-and-focus/ | |
# https://github.com/sourcegraph/thyme | |
[Unit] | |
Description=Call thyme to save windows usage to json for statistics | |
[Service] | |
Type=oneshot | |
ExecStart=/home/shibbiry/go/bin/thyme track -o /home/shibbiry/logs/thyme.json | |
# if thyme has not finished in 5 seconds, consider it failed and kill it |
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
#include <cstddef> | |
#include <cstdint> | |
#include <list> | |
#include <vector> | |
#include <functional> // use std::hash<Key> | |
#include <memory> // unique_ptr | |
#include <stdexcept> // out_of_range | |
#include <iostream> | |
#include <string> | |
#include <unordered_map> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# becomes red if previous command's result is not zero | |
# records time | |
# looks kinda nice | |
function red_if_nonzero { | |
RETVAL=$?; # get status code of the previously run command | |
[ $RETVAL -ne 0 ] && tput setaf 1; # if it's not 0, use color red | |
return 0; | |
} |