Skip to content

Instantly share code, notes, and snippets.

set.seed(42)
library(sjSDM)
com = simulate_SDM(env = 2L, species = 4L)
Y = com$response
data = com$env_weights
coords = data.frame(X=rnorm(100), Y = rnorm(100))
model <- sjSDM(Y = Y, env = data, device = "cpu")
library(keras)
library(dplyr)
data = read.csv("Earthworm/1804_2_sWormModelData.csv")[,-1]
str(data)
names(data)
sites =
data %>%
filter(Study_Name!="birkhofer2013")
use_session_with_seed(1,disable_parallel_cpu = FALSE)
model = keras_model_sequential()
model %>%
layer_dense(input_shape = ncol(x), units = 10, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units = 10, activation = "relu") %>%
layer_dropout(0.2) %>%
layer_dense(units = 3, activation = "softmax")
model %>%
compile(
library(keras)
use_session_with_seed(1,disable_parallel_cpu = FALSE)
data = iris[sample(nrow(iris)),]
y = data[, "Species"]
x = data[,1:4]
# scale to [0,1]
x = as.matrix(apply(x, 2, function(x) (x-min(x))/(max(x) - min(x))))
library(keras)
mnist <- dataset_mnist()
x_train <- mnist$train$x
y_train <- mnist$train$y
x_test <- mnist$test$x
y_test <- mnist$test$y
# 28*28 = 784
x_train <- array_reshape(x_train, c(nrow(x_train), 784))