Skip to content

Instantly share code, notes, and snippets.

View rplzzz's full-sized avatar

Robert Link rplzzz

  • University of Virginia
  • Charlottesville, VA
View GitHub Profile
@rplzzz
rplzzz / save-restore-pkgs.R
Created August 27, 2019 21:57
R functions for saving the list of installed packages and then reinstalling them all when you upgrade R
savepkgs <- function(saveloc)
{
instpkg <- installed.packages()
cranpkg <- available.packages()
iscran <- instpkg[,'Package'] %in% cranpkg[,'Package']
pkgdata <- data.frame(package=instpkg[,'Package'], iscran=iscran, instvers=instpkg[,'Version'])
write.csv(pkgdata, saveloc)
}
restore_pkgs <- function(pkglistfile)
@rplzzz
rplzzz / conv_xpose.py
Created August 10, 2018 20:43
How to use the transpose convolution function in TensorFlow
## a batch of 3 4x4x2 images as input. We will upsample these to 8x8
input_data = np.ones([3, 4, 4, 2])
filter_shape = [3,3,4,2] # width, height, channels-out, channels-in
tconv_filter = np.ones(filter_shape) # make the filter all ones so that we can manually calculate the output
# obviously, having all the filter channels have the same coefficients defeats
# the purpose of having multiple channels, but this is just an example
output_shape = [8, 8, 4] # width, height, channels-out (notice we don't have the batch size dimension -- more on that later)
## set up the slots for the data
@rplzzz
rplzzz / gcam2nc.R
Last active August 29, 2015 14:07
Illustration of how to use the R sp, raster, and ncdf packages to output GCAM data in netCDF format
library(sp)
library(rgdal)
library(raster)
library(ncdf)
##aez map
## extract data from shape file
GIS_DIR <- "./cropdata"
GIS_FILE <- "GCAM_region_AEZ"
require(igraph)
require(googleVis)
g <- graph.tree(24, children = 4)
set.seed(123)
E(g)$weight = rpois(23, 4) + 1
edgelist <- get.data.frame(g)
colnames(edgelist) <- c("source","target","value")
edgelist$source <- LETTERS[edgelist$source]
edgelist$target <- LETTERS[edgelist$target]
var empty_list = function(selector) {
return selector(undefined, undefined, true);
};
var prepend = function(el, list) {
return function(selector) {
return selector(el, list, false);
};
};
var head = function(list) {
@kogakure
kogakure / .gitignore
Last active December 17, 2023 08:21
Git: .gitignore file for LaTeX projects
*.acn
*.acr
*.alg
*.aux
*.bak
*.bbl
*.bcf
*.blg
*.brf
*.bst