Skip to content

Instantly share code, notes, and snippets.

View chanshing's full-sized avatar

Shing Chan chanshing

  • University of Oxford
  • Oxford
  • 10:01 (UTC +01:00)
  • LinkedIn in/shingc
View GitHub Profile
@moritzkoerber
moritzkoerber / release.yml
Created August 14, 2021 09:58
Manual PyPi Release GitHub Actions Workflow
name: Manual PyPi Release
on:
workflow_dispatch:
inputs:
package_repository:
description: '"testpypi" or "pypi"'
required: true
tag:
required: true
@mx-moth
mx-moth / chunksof.py
Last active August 12, 2021 21:56
Split a generator up in to chunks of size `n`, without walking the list or keeping items in memory needlessly
from itertools import chain, islice
class splitter:
"""Helper class for splitat."""
def __init__(self, iterable, count):
self.iterator = iter(iterable)
self.count = count
self.queue = []
import torch
import torch.nn
from torch.autograd import Variable
def pairwise_euclidean(samples):
B = samples.size(0)
samples_norm = samples.mul(samples).sum(1)
samples_norm = samples_norm.expand(B, B)
@rejunity
rejunity / histogram_loss.py
Created April 16, 2017 07:19
Histrogram style loss based on "Stable and Controllable Neural Texture Synthesis and Style Transfer Using Histogram Losses" (4.3)
# output -- per layer feature-map of the image we optimize
# style -- per layer feature-map of the style image we want to copy
# histogram_matching() -- see reference numpy implementation http://stackoverflow.com/a/33047048/7873678
output_remapped = histogram_matching(output, style, nbins=1024) # non-differentiable
sum((output_image - output_remapped)**2) # gradients assume that output_remapped ~~ const
@DianaEromosele
DianaEromosele / Change "origin" of your GIT repository
Created August 7, 2016 00:31
Change "origin" of your GIT repository
$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@rain1024
rain1024 / tut.md
Last active June 26, 2024 09:50
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@hotpxl
hotpxl / swap-ctrl-caps.reg
Last active April 23, 2020 19:13
Swap control and caps lock on Windows
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00