Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Rosinski machinatoonist

View GitHub Profile
@machinatoonist
machinatoonist / gist:7c95c31f2ff427f434159af9a143cda0
Created Aug 11, 2022
Error when attempting to specify vocabulary size in fastai text_classifier_learner with AWD_LTSM
View gist:7c95c31f2ff427f434159af9a143cda0
def train(arch, train_df=train_df, accum=1, epochs=12):
dls = TextDataLoaders.from_df(train_df,text_col='desc',label_col='label',valid_pct=0.2,bs=64//accum)
cbs = GradientAccumulation(64) if accum else []
# learn = text_classifier_learner(dls, arch=AWD_LSTM, drop_mult=0.5, metrics=[accuracy], cbs=cbs).to_fp16()
learn = text_classifier_learner(dls, arch=AWD_LSTM(vocab_sz=200, emb_sz=20, n_hid=10, n_layers=2, pad_token=1,
hidden_p=0.2, embed_p=0.02, input_p=0.1, weight_p=0.2),
drop_mult=0.5, metrics=[accuracy], cbs=cbs).to_fp16()
learn.fine_tune(epochs, 0.01)
return learn
@machinatoonist
machinatoonist / Convert .mov or .MP4 to .gif.md
Created May 6, 2022 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal
View Convert .mov or .MP4 to .gif.md

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@machinatoonist
machinatoonist / hello.py
Created Oct 10, 2021
Using Gists to write code and include within Github repos
View hello.py
def hello():
return x+y
@machinatoonist
machinatoonist / correlation_funnel_plot.R
Created Aug 7, 2021
How to create a correlation funnel plot
View correlation_funnel_plot.R
library(correlationfunnel)
library(dplyr)
data("ames")
data_prep <- ames
### Step 1 - Prepare Data as Binary Features
# We use the `binarize()` function to produce a feature set of binary (0/1) variables.
@machinatoonist
machinatoonist / scrape_pm_media.R
Last active Jul 24, 2021
How to Create a Large Structured Text Dataset Using R
View scrape_pm_media.R
# How to analyse 2.2 million words from 786 different speeches and interviews
# by the Prime Minister of Australia from Jan 2020- July 2021. After hearing
# one of the PM's speeches I began to wonder if transcripts of all his
# speeches and interviews were publicly available. It turns out they are!
# This code extract shows how I scraped the full text of 786 speeches and interviews
# using the #rvest package which comes with tidyverse.
# I recommend @Julia Silge's #Tidytext tools for analysis.