Skip to content

Instantly share code, notes, and snippets.

Avatar

kukuruza

  • Carnegie Mellon University
  • Pittsburgh PA, USA
View GitHub Profile
@jeasinema
jeasinema / weight_init.py
Last active Oct 14, 2022
A simple script for parameter initialization for PyTorch
View weight_init.py
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.init as init
def weight_init(m):
'''
@jimfleming
jimfleming / colorize.py
Last active Nov 25, 2022
A utility function for TensorFlow that maps a grayscale image to a matplotlib colormap for use with TensorBoard image summaries.
View colorize.py
import matplotlib
import matplotlib.cm
import tensorflow as tf
def colorize(value, vmin=None, vmax=None, cmap=None):
"""
A utility function for TensorFlow that maps a grayscale image to a matplotlib
colormap for use with TensorBoard image summaries.
@gyglim
gyglim / tensorboard_logging.py
Last active Oct 23, 2022
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
View tensorboard_logging.py
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np
@jakevdp
jakevdp / discrete_cmap.py
Last active Jan 10, 2023
Small utility to create a discrete matplotlib colormap
View discrete_cmap.py
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@drmalex07
drmalex07 / getopt-example.sh
Last active Nov 10, 2022
A small example on Bash getopts. #bash #getopt #getopts
View getopt-example.sh
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
@detunized
detunized / sort-libs.rb
Last active Jan 19, 2023
Sort static libraries in the topological order
View sort-libs.rb
#!/usr/bin/env ruby
# This script sorts static libraries in the topological order suitable for
# passing to ld. No need for --start-group/--end-group anymore. Should speed
# up the linking a bit. When the libraries contain actual circular dependecies
# the script will detect minimal groups of those and surround them with
# --start-group/--end-group.
#
# To run you need Linux (maybe OS X), Ruby 1.9+ and the rgl gem installed:
#
@YukiSakamoto
YukiSakamoto / hdf5_simple.cpp
Created Aug 23, 2013
simple example to write hdf5 using c++.
View hdf5_simple.cpp
#include <string>
#include <iostream>
#include "H5Cpp.h"
#define MAX_NAME_LENGTH 32
const std::string FileName("SimpleCompound.h5");
const std::string DatasetName("PersonalInformation");
const std::string member_age("Age");
const std::string member_sex("Sex");
const std::string member_name("Name");