Skip to content

Instantly share code, notes, and snippets.

View yuhangwang's full-sized avatar

StevenW yuhangwang

View GitHub Profile
@yuhangwang
yuhangwang / torch_func_opt_example.py
Created December 10, 2023 10:14 — forked from madagra/torch_func_opt_example.py
Fitting a function with functional PyTorch
import numpy as np
import torch
from torch import nn
from torch import Tensor
from torch.func import functional_call
import torchopt
import matplotlib.pyplot as plt
class SimpleNN(nn.Module):
@yuhangwang
yuhangwang / entry.sh
Created July 12, 2022 03:35 — forked from xkortex/entry.sh
dockerfile entrypoint for activating conda environment
#!/bin/bash
## Entrypoint for docker RUN directives as well as ENTRYPOINT with conda env
## Enable by adding:
## COPY entry.sh ./
## SHELL ["/entry.sh", "/bin/bash", "-c"]
##
## Optionally, set the following env to select a conda env to run in
## ENV CONDA_DEFAULT_ENV=foo
## You may also want to add something like
## RUN conda init bash && echo 'conda activate "${CONDA_TARGET_ENV:-base}"' >> ~/.bashrc
@yuhangwang
yuhangwang / rst_to_md.sh
Created March 16, 2022 07:54 — forked from zaiste/rst_to_md.sh
Convert RST to Markdown using Pandoc
FILES=*.rst
for f in $FILES
do
filename="${f%.*}"
echo "Converting $f to $filename.md"
`pandoc $f -f rst -t markdown -o $filename.md`
done
# see: https://www.deepmind.com/blog/article/Competitive-programming-with-AlphaCode
# Why AlphaCode generated an unused variable `c` to store a string that has no use at all?
t = int(input())
for i in range(t):
s = input()
t = input()
a = []
b = []
for j in s:
a.append(j)
@yuhangwang
yuhangwang / Install_tmux
Created August 14, 2021 03:18 — forked from simme/Install_tmux
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@yuhangwang
yuhangwang / conf_gen.py
Created June 11, 2020 19:39 — forked from tdudgeon/conf_gen.py
Conformer generation using RDKit
import sys
from rdkit import Chem
from rdkit.Chem import AllChem, TorsionFingerprints
from rdkit.ML.Cluster import Butina
def gen_conformers(mol, numConfs=100, maxAttempts=1000, pruneRmsThresh=0.1, useExpTorsionAnglePrefs=True, useBasicKnowledge=True, enforceChirality=True):
ids = AllChem.EmbedMultipleConfs(mol, numConfs=numConfs, maxAttempts=maxAttempts, pruneRmsThresh=pruneRmsThresh, useExpTorsionAnglePrefs=useExpTorsionAnglePrefs, useBasicKnowledge=useBasicKnowledge, enforceChirality=enforceChirality, numThreads=0)
return list(ids)
@yuhangwang
yuhangwang / functional-rust.md
Last active May 19, 2020 13:01
Functional Programming in Rust
@yuhangwang
yuhangwang / functional-deep-learning.md
Last active April 25, 2020 20:01
Functional Deep Learning

Here is a list tools for building a functional deep learning software stack.

  1. Grenade: https://github.com/HuwCampbell/grenade
    "Grenade is a composable, dependently typed, practical, and fast recurrent neural network library for concise and precise specifications of complex networks in Haskell."

Here is a list of blogs/tutorials for doing functional machine learning.

  1. "Machie Learning in Haskell" https://mmhaskell.com/machine-learning
@yuhangwang
yuhangwang / gnu-compiler-optimization-flags.md
Last active January 30, 2020 20:14
GNU Compilier Optimization Flags

Optimization flags

  • -funsafe-loop-optimizations
    If given, the loop optimizer will assume that loop indices do not overflow, and that the loops with nontrivial exit condition are not infinite. This enables a wider range of loop optimizations even if the loop optimizer itself cannot prove that these assumptions are valid. Using -Wunsafe-loop-optimizations, the compiler will warn you if it finds this kind of loop.
  • -funsafe-math-optimizations
    Allow optimizations for floating-point arithmetic that
  • (a) assume that arguments and results are valid and
@yuhangwang
yuhangwang / gnu-intel-linking.md
Last active January 30, 2020 19:53
GNU compiler + Intel MKL & MPI library linking

GNU Fortran compiler

-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_scalapack_lp64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_blacs_intelmpi_lp64 -lgomp -lpthread -lm -ldl

compiler option: -m64 -I${MKLROOT}/include

GNU C Compiler