Skip to content

Instantly share code, notes, and snippets.

View RichardScottOZ's full-sized avatar

RichardScottOZ

  • Australia
View GitHub Profile
@chmodsss
chmodsss / fine_tune_glove.py
Created April 19, 2020 06:26
Fine tuning glove embeddings using Mittens
import csv
import numpy as np
from collections import Counter
from nltk.corpus import brown
from mittens import GloVe, Mittens
from sklearn.feature_extraction import stop_words
from sklearn.feature_extraction.text import CountVectorizer
def glove2dict(glove_filename):
@ElefHead
ElefHead / Installing_theano_and_pymc3.md
Last active January 16, 2025 21:03
A guide to install pymc3, theano with CUDA on windows 10 -- Dec 2019

I am writing this gist because I spent 6 hours navigating links trying to get Theano to work with CUDA on windows 10. Hopefully, you wouldn't have to. Once theano is setup and running, you can install pymc3 and it all works. I had tensorflow-gpu setup and running on windows 10; it isn't as simple as pip install theano.

I will list down the instructions, with the links where I found them. Hope this helps someone.

This set of instructions depend on anaconda. Also, this is sort of hacky in the end.

Ok let's begin.


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / README.md
Last active March 16, 2022 08:40
Rip data from a pseudocolour image, given the colourmap

Ripping data from pseudocolour images

Because viridis, like all good colourmaps, is perceptually linear, it's easy to get the data from it: just use a greyscale version of the image. But you can rip the data from any pseudocolour image if you know (or can guess) the colourmap.

In the rip-data.py example, here's the approach:

  1. Read the image and transform the values to the range 0-1.
  2. Guess the colourmap, in this case it's viridis. Matplotlib conveniently gives us the RGB triples that make up a colourmap.
@prakharcode
prakharcode / resample.py
Last active September 1, 2021 04:42
Resample, reprojection and stacking of bands using rasterio
band_dict = {
""" dictonary containing all the bands that are to be stacked
in the following format:
band_index : "path/to/band"
"""
}
dst_projection = 'EPSG:4326' # the final projection
ref_band = "path/to/ref_band/" # the band that you want as a reference
@andrewdhicks
andrewdhicks / dask-median.ipynb
Created March 13, 2019 23:04
median() for a dask-backed xarray
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jesserobertson
jesserobertson / grd_to_tif.py
Last active March 12, 2025 06:43
Convert all Geosoft *.grd files to geotiff in a directory (recursively)
import pathlib
from itertools import product
from tqdm import tqdm
import rasterio
import geosoft
import geosoft.gxpy.gx as gx
import geosoft.gxpy.coordinate_system as gxcs
import geosoft.gxpy.grid as gxgrid
@jacobtomlinson
jacobtomlinson / Dask on Fargate from scratch.ipynb
Last active February 17, 2025 03:48
Dask on Fargate from scratch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jakelevi1996
jakelevi1996 / Running TensorFlow Sessions inside sub-processes.md
Last active July 4, 2022 19:13
Running TensorFlow Sessions inside sub-processes

Running TensorFlow Sessions inside sub-processes

In some applications of machine learning/TensorFlow, it is desirable to start multiple processes, and have separate training procedures running concurrently in each of those processes. A useful Python method for achieving this is the multiprocessing.pool.Pool.map() method (or the equivalent starmap() method when the target function takes multiple arguments; see the section "Process Pools" from the description of the multiprocessing module in the Python Library Reference).

The Pool.map() method takes a target-function and a list (or more generally an iterable) of arguments, and returns an equivalent iterable of the results of the function evaluated on each member of the argument-list (which is similar to the [built-in Python function map()

@parente
parente / README.md
Last active March 7, 2023 11:50
Jupyter Tidbit: IPython's ! returns an SList

Summary

IPython shell assignment (the ! operator) evaluates a command using the local shell (e.g., bash) and returns a string list (IPython.utils.text.SList). An SList is a list-like object containing "chunks" of stdout and stderr, properties for accessing those chunks in different forms, and convenience methods for operating on them.

Example

Binder

The SList.ipynb notebook below uses SList properties to access the output of a shell command as a list-like of strings, a newline-separated string, a space-separated string, and a list of pathlib.Path objects. The notebook then uses the SList.fields() and SList.grep() methods to extract columns from and search command output.