Skip to content

Instantly share code, notes, and snippets.

View f0nzie's full-sized avatar

Alfonso R. Reyes f0nzie

  • Oil Gains Analytics
  • Houston, Texas
View GitHub Profile
@f0nzie
f0nzie / softmax.py
Created September 7, 2017 00:24
softmax
def softmax(x):
"""Calculates the softmax for each row of the input x.
Your code should work for a row vector and also for matrices of shape (n, m).
Argument:
x -- A numpy matrix of shape (n,m)
Returns:
s -- A numpy matrix equal to the softmax of x, of shape (n,m)
@f0nzie
f0nzie / image_to_colvector.py
Created September 7, 2017 00:32
Convert a 3D array to a column vector
def image2vector(image):
"""
Argument:
image -- a numpy array of shape (length, height, depth)
Returns:
v -- a vector of shape (length*height*depth, 1)
"""
v = image.reshape((image.shape[0] * image.shape[1] * image.shape[2], 1))
@f0nzie
f0nzie / sigmoid.py
Created September 7, 2017 00:35
Compute the sigmoid of x
def sigmoid(x):
"""
Compute the sigmoid of x
Arguments:
x -- A scalar or numpy array of any size
Return:
s -- sigmoid(x)
"""
@f0nzie
f0nzie / README.md
Created October 15, 2017 21:33 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@f0nzie
f0nzie / table-make-from_text_using_readr.md
Created February 3, 2019 03:55
Make a table from text
title output
R Notebook
html_notebook
@f0nzie
f0nzie / table-make-from_text_using_data_table.md
Created February 3, 2019 04:19
Make a table from text using data.table
title output
R Notebook
html_notebook
library(data.table)
fread("A,B
1,2
@f0nzie
f0nzie / table-make-from_text-data_table-tsv.md
Created February 3, 2019 04:33
Make a table from text (tsv) using data.table
title output
R Notebook
html_notebook
write.table(read.table(text = "
 CHR_A     BP_A          SNP_A  CHR_B         BP_B          SNP_B           R2 
 1    154834183      rs1218582      1    154794318      rs9970364    0.0929391 
@f0nzie
f0nzie / rTorch_linear_regression.Rmd
Created June 11, 2019 04:39
PyTorch - Linear Regression in R - rsuite version
# One chunk - Linear Regression in R
Source: https://medium.com/dsnet/linear-regression-with-pytorch-3dde91d60b50
```{r}
# Force using local Python environment
if (.Platform$OS.type == "unix") {
reticulate::use_python(python = file.path(script_path, "..", "conda", "bin",
"python3"), require = TRUE)
} else if (.Platform$OS.type == "windows") {
@f0nzie
f0nzie / set_env.R
Created July 15, 2019 22:20
set_env script with rprojroot
# find_rsuite_root <- function(key = "PARAMETERS") rprojroot::find_root(key)
ace_rsuite <- find_rsuite_root()
lib_path <- file.path(ace_rsuite, "libs")
sbox_path <- file.path(ace_rsuite, "sbox")
if (!file.exists(lib_path)) {
lib_path <- file.path(find_rsuite_root(), "deployment", "libs")
sbox_path <- file.path(find_rsuite_root(), "deployment", "sbox")
}
@f0nzie
f0nzie / .Rprofile
Created July 15, 2019 23:12
.Rprofile for master project
find_rsuite_root <- function(key = "PARAMETERS") rprojroot::find_root(key)
source(file.path(find_rsuite_root(), 'R', 'set_env.R'), chdir = TRUE)
options(rsuite.cache_path = "~/.rsuite/cache")
options(rsuite.user_templ_path = "~/.rsuite/templates")