Skip to content

Instantly share code, notes, and snippets.

👨‍💻
coding as usual

Al Asaad alstat

👨‍💻
coding as usual
Block or report user

Report or block alstat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View explanation-of-apply.R
set.seed(1)
x1 <- rnorm(10)
x2 <- rnorm(10)
out <- cbind(x1, x2)
colMeans(out)
# colMeans can be computed as follows as well
apply(out, 2, mean)
# apply - applies a mean function to column (indicated by 2) of out matrix
View code-sir-aljo-mcmc.R
# Simulating the data
set.seed(73735911)
#set.seed(737377911)
n=100;nu=5;alpha=2;beta=2;sig=1;true=c(alpha,beta,nu)
x=rnorm(n,1,1)
y=alpha+beta*x+sig*rt(n,nu)
par(mfrow=c(1,1))
plot(x,y, col='blue3', pch=19)
@alstat
alstat / code-turing.jl
Created Feb 4, 2019
Turing.jl Tutorial on Bayesian Linear Regression
View code-turing.jl
using Turing, Distributions
# Import RDatasets.
using RDatasets
# Import MCMCChain, Plots, and StatPlots for visualizations and diagnostics.
using MCMCChain, Plots, StatPlots
# MLDataUtils provides a sample splitting tool that's very handy.
using MLDataUtils
View sir-aljo.r
rz_helper = function() {
y1 = rexp(1, 1) # step 1
y2 = rexp(1, 1) # step 2
# step 3
while (y2 <= ((y1 - 1)^2)/2) {
y1 = rexp(1, 1)
}
# step 4
View al-ilm-nn-pyr-keras-5.py
f, a = subplots(10, 20)
for i in arange(10):
for j in arange(20):
a[i, j].imshow(x_train[j + 20 * i])
a[i, j].axis("off")
a[i, j].set_adjustable('box-forced')
f.savefig("img1.png", bbox_inches='tight', pad_inches = 0)
View al-ilm-nn-pyr-keras-3.r
items <- list(x_train, y_train, x_test, y_test)
dim_formatter <- function (x) {
if (length(dim(x)) > 2)
paste("(", dim(x)[1], ", ", dim(x)[2], " , ", dim(x)[3], " , ", dim(x)[4], ")", sep = "")
else
paste("(", dim(x)[1], ", ", dim(x)[2], ")", sep = "")
}
# training set
View al-ilm-nn-pyr-keras-4.py
items = [x_train, y_train, x_test, y_test]
# training set
[type(item) for item in items[:2]] # [<type 'numpy.ndarray'>, <type 'numpy.ndarray'>]
[item.shape for item in items[:2]] # [(50000, 32, 32, 3), (50000, 1)]
# testing set
[type(item) for item in items[2:]] # [<type 'numpy.ndarray'>, <type 'numpy.ndarray'>]
[item.shape for item in items[2:]] # [(10000, 32, 32, 3), (10000, 1)]
View al-ilm-nn-pyr-keras-2.r
cifar100 <- dataset_cifar100(label_mode = "fine")
x_train <- cifar100$train$x; y_train <- cifar100$train$y
x_test <- cifar100$test$x; y_test <- cifar100$test$y
View al-ilm-nn-pyr-keras-3.py
(x_train, y_train), (x_test, y_test) = cifar100.load_data(label_mode = "fine")
View al-ilm-nn-pyr-keras-3.R
library(keras)
# Define the constants
CONST_N <- 2000
CONST_EPOCHS <- 30
CONST_PIXEL_MAX <- 255
You can’t perform that action at this time.