This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
sudo apt install -y --no-install-recommends software-properties-common dirmngr | |
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc | |
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" | |
sudo apt install -y r-base r-base-core r-recommended r-base-dev | |
sudo apt install -y libssl1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_gen <- function(lr) { | |
lin <- nn_linear(2, 1) #b0 e b1 | |
opt <- torch::optim_adam(lin$parameters, lr = lr) | |
return(list(lin = lin, opt = opt)) | |
} | |
model_fit <- function(model) { | |
model$opt$zero_grad() | |
pred <- model$lin(x) # b0 + b1*x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Cartao Corporativo dos Presidentes do Brasil - 2003 a 2022" | |
author: "Athos Damiani" | |
--- | |
```{r} | |
library(tidyverse) | |
library(lubridate) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(purrr) | |
library(tidyverse) | |
# Sys.setenv(EASYNVEST_AUTH_TOKEN = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NTEyNjU5NjMsImV4cCI6MTY1MTI5NDc2MywiaXNzIjoiaHR0cHM6Ly9hcGkuZWFzeW52ZXN0LmNvbS5ici9hdXRoIiwiYXVkIjpbImh0dHBzOi8vYXBpLmVhc3ludmVzdC5jb20uYnIvYXV0aC9yZXNvdXJjZXMiLCJodHRwczovL3d3dy5lYXN5bnZlc3QuY29tLmJyIl0sImNsaWVudF9pZCI6Ijg3NmRhYjIxOTA0NjQ4ODRiZjliMDkyYWExNDA3NTg1Iiwic3ViIjoiMzIzNzM3NjI4MDMiNsaWVudElkXCI6XCI4NzZkYWIyMTkwNDY0ODg0YmY5YjA5MmFhMTQwNzU4NVwiLFwiTmFtZVwiOlwiUG9ydGFsL0hvbWUgQnJva2VyXCIsXCJJbnRlcm5hbFwiOmZhbHNlfSIsImNpYSI6Ijo6ZmZmZjoxMC42NS43Mi4xNjgiLCJkZXZpY2VfaWQiOiI0ZmZhNjYwNDAzYWZlOGM2OTU2YWI5MzkxZDhjOWJlYSIsInNjb3BlIjpbIm9wZW5pZCIsImh0dHBzOi8vd3d3LmVhc3ludmVzdC5jb20uYnIiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicGFzc3dvcmQiXX0.WsLEshN75bVckTKOX5HGHRpTVPcvmbahb77Ko6qs_Ho") | |
notas_de_negociacao <- function( | |
end_date = lubridate::today() - lubridate::days(1), | |
start_date = as.Date(end_date) - lubridate::days(89) | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Kaggle: Guess The Correlation (feat. {torchdatasets})" | |
date: "2021-01-10" | |
tags: ["torch", "deep learning", "r", "machine learning"] | |
categories: ["tutoriais", "r"] | |
banner: "img/banners/guess-the-correlation.png" | |
author: ["Athos"] | |
summary: "Solução para o Kaggle Guess The Correlation com {torch}." | |
draft: true | |
editor_options: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
animation::saveGIF({ | |
f <- function(t, l = 1) (t>0)*exp(-t*l) | |
h <- function(t) as.numeric(abs(t) < 1) | |
g <- function(t, tau = seq(-2,10,l=1000)) mean(f(tau) * h(t-tau)) | |
par(mfrow = c(2,1)) | |
tau <- seq(-2,10,l=1000) | |
ts <- seq(-2,10,l=100) | |
gs <- c() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(torch) | |
library(mvtnorm) | |
library(datasauRus) | |
set.seed(42) | |
# x <- mvtnorm::rmvnorm(100, c(1,2), sigma = matrix(c(1.2,1,1,1.1), 2)) | |
plot(x) | |
x <- as.matrix(datasauRus::datasaurus_dozen[datasaurus_dozen$dataset == "dino",c("x", "y")]) | |
x <- torch_tensor(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f <- function(x) cos(x*20) | |
expi <- function(x) cos(x) + sin(x)*1i | |
par(mfrow = c(1,2)) | |
L <- 40 | |
medias_Re <- c() | |
fs <- c() | |
as <- seq(0.01, 1, l = 140) | |
animation::saveGIF({ | |
for(a in as) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
a <- system.file("waves_yesno/1_1_0_1_1_0_1_1.wav", package = "torchaudio") | |
# mp3 --------------------------------------------------------------------- | |
a <- system.file("sample_audio_1.mp3", package = "torchaudio") | |
mp3_bm <- bench::mark( | |
torchaudio:::av_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(), | |
torchaudio:::tuneR_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(), | |
torchaudio:::av_read_mp3_or_wav(a), |
NewerOlder