Skip to content

Instantly share code, notes, and snippets.

View javierluraschi's full-sized avatar
👨‍💻
Coding @hal9ai

Javier Arturo Porras Luraschi javierluraschi

👨‍💻
Coding @hal9ai
View GitHub Profile
@javierluraschi
javierluraschi / sparklyr-k8s-google-clouid.md
Last active February 2, 2020 17:18
Using sparklyr with Kubernetes and Google Cloud

Adapted for sparklyr from cloud.google.com/solutions/spark-on-kubernetes-engine:

First, configure the cluster using Google Cloud client and kubectl:

gcloud config set compute/zone us-central1-f
gcloud container clusters create spark-on-gke --machine-type n1-standard-2

Next we need to bind the cluster admin to your email (you can retrieve your account email with gcloud config get-value account if needed):

@javierluraschi
javierluraschi / multiverse.md
Last active June 14, 2019 05:11
Multiverse Hex
library(tidyverse)
library(rayrender)
set.seed(2019)

spheres <- expand.grid(y = (1:50) / 5 - 5, z = (1:50) / 5 - 5) %>%
  tibble::as_tibble()

noise <- ambient::noise_perlin(c(100, 100, 1))
@javierluraschi
javierluraschi / multiverse-youtube-slide.Rmd
Last active December 2, 2019 23:22
Multiverse YouTube Slide
---
title: "Using GPUs with TensorFlow and Docker"
subtitle: Multiverse Video Series
author: Javier Luraschi
output:
revealjs::revealjs_presentation:
df_print: paged
self_contained: true
theme: moon
---
@javierluraschi
javierluraschi / karpathys-tweets-rstats.R
Created December 11, 2019 01:57
Karpathy's Tweets per Month
library(tidyverse)
rtweet::get_timeline(rtweet::as_userid("karpathy"), n = 1000) %>%
mutate(year = as.character(lubridate::year(as.Date(created_at))),
month = lubridate::month(as.Date(created_at))) %>%
group_by(year, month) %>%
count(year, month) %>%
ggplot(aes(month, n, color = year)) + geom_point() +
geom_smooth(method = "lm", alpha = .15, aes(fill = year)) +
ggtitle("Karpathy's Tweets per Month")
@javierluraschi
javierluraschi / multiverse-youtube-mlflow-intro.R
Created January 4, 2020 08:03
Multiverse YouTube MLflow Intro
library(glmnet)
wine_file <- pins::pin("https://raw.githubusercontent.com/rstudio/mlflow-example/master/wine-quality.csv")
train <- read.csv(wine_file)
train_x <- as.matrix(train[, !(names(train) == "quality")])
train_y <- train[, "quality"]
alpha <- mlflow_log_param("alpha", 0.7, "numeric")
@javierluraschi
javierluraschi / spark-tensorflow-barrier-emr-setup.md
Last active January 10, 2020 22:54
Initial setup to use Spark and TensorFlow Distributed using EMR

This script requires an Amazon EMR cluster with one master and three nodes:

library(sparklyr)
sc <- spark_connect(master = "yarn", spark_home = "/usr/lib/spark/", config = list(
    spark.dynamicAllocation.enabled = FALSE,
    `sparklyr.shell.executor-cores` = 8,
    `sparklyr.shell.num-executors` = 3,
    sparklyr.apply.env.WORKON_HOME = "/tmp/.virtualenvs"))
@javierluraschi
javierluraschi / spark-keras-image-classify.md
Last active January 20, 2020 17:01
Image classification with Spark and Keras

This script makes use of an Amazon EMR cluster with one master and three nodes:

install.packages("sparklyr")
install.packages("keras")

sc <- spark_connect(
  master = "yarn",
  spark_home = "/usr/lib/spark/",
  config = list("sparklyr.apply.env.WORKON_HOME"  = "/tmp/.virtualenvs"))
@javierluraschi
javierluraschi / torch-build-windows-rtools.md
Last active January 13, 2020 21:19
Building Torch in Windows with RTools 4.0
@javierluraschi
javierluraschi / spark-delta-lake-mlflow.md
Last active March 27, 2021 19:13
Using Spark, Delta Lake and MLflow
title output
Using Spark, Delta Lake and MLflow
html_notebook

First we define helper functions,

delta_version <- function(sc, path) {
  invoke_static(sc, "io.delta.tables.DeltaTable", "forPath", spark_session(sc), path) %>%
@javierluraschi
javierluraschi / pytorch-example-visual-studio.cpp
Created January 16, 2020 23:50
PyTorch 1.3.0 example with Visual Studio
#ifdef _MSC_VER
#pragma warning( disable : 4146 )
#endif
#include <iostream>
#include <torch/torch.h>
struct Net : torch::nn::Module {
Net(int64_t N, int64_t M) {
W = register_parameter("W", torch::randn({ N, M }));