Skip to content

Instantly share code, notes, and snippets.

View priancho's full-sized avatar

Han-Cheol Cho priancho

View GitHub Profile
@bitsgalore
bitsgalore / imagemagick-openjpeg-build-install.md
Created February 26, 2020 14:14
Imagemagick + openjpeg build and install notes

ImageMagick / OpenJPEG build and install notes

I always end up getting this wrong; steps below worked for Linux Mint 19.3 (based on Ubuntu 18.04). Build/installation order is important; JPEG 2000 support in ImageMagick only works if OpenJPEG is found at build time, so we have to start with that. Note that for OpenJPEG an 'openjpeg-dev' Debian package exists. As I'm not entirely sure this is the most up-to-date version, and JPEG 2000 support is important for me, I'm compiling this library from the sources here. Otherwise everything under the 'OpenJPEG' could probably be subsituted by the one-liner sudo at-get install openjpeg-dev).

Cmake

@endolith
endolith / DFT_ANN.py
Last active July 21, 2024 13:05
Training neural network to implement discrete Fourier transform (DFT/FFT)
"""
Train a neural network to implement the discrete Fourier transform
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
import matplotlib.pyplot as plt
N = 32
batch = 10000
@jacobkimmel
jacobkimmel / make_one_hot.py
Last active May 15, 2021 04:02
Generate one hot labels from integer labels in PyTorch
def make_one_hot(labels, C=2):
'''
Converts an integer label torch.autograd.Variable to a one-hot Variable.
Parameters
----------
labels : torch.autograd.Variable of torch.cuda.LongTensor
N x 1 x H x W, where N is batch size.
Each value is an integer representing correct classification.
C : integer.
@erogol
erogol / NLL_OHEM.py
Last active January 29, 2023 21:02
Online hard example mining PyTorch
import torch as th
class NLL_OHEM(th.nn.NLLLoss):
""" Online hard example mining.
Needs input from nn.LogSotmax() """
def __init__(self, ratio):
super(NLL_OHEM, self).__init__(None, True)
self.ratio = ratio
@dentechy
dentechy / WSL-ssh-server.md
Last active July 14, 2024 03:54
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:
@HarshaVardhanBabu
HarshaVardhanBabu / Instructions_UML_Python.rst
Last active July 16, 2024 11:34
Generating UML diagrams in python using pyreverse

Requirements

  1. Install Pylint from Install. If you have anaconda already installed use pip install -U pylint to update the Pylint so that pyreverse is added to the scripts folder.

  2. You need to install Graphviz as the pyreverse generates the UML diagrams in dot format and needs the dot.exe provided by Graphviz. Once Graphviz is installed make sure the bin folder is added to the PATH variable so that pyreverse can find it at run time. "the command pyreverse generates the diagrams in all formats that graphviz/dot knows." (Reference

  3. Now add the path of python modules for which you want to generate the documentation to PYTHONPATH.

  4. Use pyreverse -S <modulename> to generate dot files in the current folder

    Usage:

@sonots
sonots / nvvp.md
Last active July 3, 2024 21:43
How to use NVIDIA profiler

Usually, located at /usr/local/cuda/bin

Non-Visual Profiler

$ nvprof python train_mnist.py

I prefer to use --print-gpu-trace.

@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active July 21, 2024 08:16
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
Tmux is a "terminal multiplexer", it enables a number of terminals to be accessed and controlled from a single terminal.
If you use Debian/Ubuntu, you can just run apt-get install tmux, and voila.
Since the title was about centos 7, then do the following step to install tmux.
(1). tmux has a library dependency on libevent which, of course, isn’t installed by default.
$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
$ tar xzvf libevent-2.0.21-stable.tar.gz
$ cd libevent-2.0.21-stable
$ ./configure && make
@karpathy
karpathy / min-char-rnn.py
Last active July 22, 2024 04:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)