Skip to content

Instantly share code, notes, and snippets.

View fkdosilovic's full-sized avatar

Filip Karlo Došilović fkdosilovic

  • Newfire Global Partners
  • Zagreb
  • 08:28 (UTC +02:00)
  • X @fkdosilovic
View GitHub Profile
@fkdosilovic
fkdosilovic / nlp-tutorials-and-workshops.md
Last active July 12, 2022 10:18
NLP Tutorials and Workshops
@99991
99991 / gpu_usage.py
Last active September 9, 2022 21:40
Get NVIDIA GPU memory usage and find free GPUs using nvidia-smi
import subprocess, getpass
def get_gpu_usage():
"""
Returns a dict which contains information about memory usage for each GPU.
In the following output, the GPU with id "0" uses 5774 MB of 16280 MB.
253 MB are used by other users, which means that we are using 5774 - 253 MB.
{
@llimllib
llimllib / hamming.md
Created December 28, 2020 17:56
One Man's View of Computer Science

Richard W. Hamming

January 1969

One Man's View of Computer Science

Abstract

A number of observations and comments are directed toward suggesting that more than the usual engineering flavor be given to computer science. The engineering

@ferrine
ferrine / network_builder.py
Last active November 10, 2023 04:43
Pytorch models from yaml files
import torch.nn
import collections
class Builder(object):
def __init__(self, *namespaces):
self._namespace = collections.ChainMap(*namespaces)
def __call__(self, name, *args, **kwargs):
try:
return self._namespace[name](*args, **kwargs)
@tux-00
tux-00 / configparser_to_dataclasses.py
Created August 20, 2018 18:20
Converts python config parser to dataclasses (easier access)
import configparser
from dataclasses import dataclass
@dataclass
class Sections:
raw_sections: dict
def __post_init__(self):
for section_key, section_value in self.raw_sections.items():
@HarshTrivedi
HarshTrivedi / pad_packed_demo.py
Last active July 5, 2024 22:47 — forked from Tushar-N/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@mivade
mivade / cli.py
Last active January 18, 2024 07:51
Using a decorator to simplify subcommand creation with argparse
"""This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@bishboria
bishboria / springer-free-maths-books.md
Last active June 8, 2024 06:39
Springer made a bunch of books available for free, these were the direct links
@dannguyen
dannguyen / catdrawer-youtube-to-gif-README.md
Last active September 20, 2023 21:02
Using youtube-dl and gifify from the command-line to make a cat gif