Skip to content

Instantly share code, notes, and snippets.

View maulberto3's full-sized avatar

Mauricio maulberto3

View GitHub Profile
@maulberto3
maulberto3 / run_mlm_big_text_files.py
Created June 8, 2023 21:27 — forked from finiteautomata/run_mlm_big_text_files.py
Train MLM with big text files (Workaround)
"""
This is a workaround for `examples/run_mlm.py` for pretraining models
with big text files line-by-line.
For the time being, `datasets` is facing some issues dealing with really
big text files, so we use a custom dataset until this is fixed.
August 3th 2021
Author: Juan Manuel Pérez
@maulberto3
maulberto3 / reduce4.js
Last active July 12, 2018 04:01
Reduce example #4
const arr = [["dog", 1], ["cat", 2], ["bear", 3]];
const func1 = ([key, v1]) => ({ [key]: v1 }); // creates an object out of the array
const func2 = (obj, prop) => Object.assign(obj, prop); // assigns each object to an accumulator object
const obj3 = arr.map(func1).reduce(func2); // nesting
console.log(JSON.stringify(obj3, null, 2)); // Prints { "dog": 1, "cat": 2, "bear": 3 }
@maulberto3
maulberto3 / reduce3.js
Last active July 12, 2018 04:01
Reduce example #3
const arr = [["dog", 1], ["cat", 2], ["bear", 3]];
const func1 = ([key, v1]) => ({ [key]: v1 }); // creates an object out of the array
const obj2 = arr.map(func1)
console.log(JSON.stringify(obj2, null, 2)); // Prints [ { "dog": 1 }, { "cat": 2 }, { "bear": 3 } ]
@maulberto3
maulberto3 / reduce2.js
Created March 2, 2018 17:53
Reduce example #2
const reducer = (accum, curr) => accum + curr;
const result = [0, 1, 2, 3, 4].reduce(reducer);
console.log("result is", result); // result is 10
@maulberto3
maulberto3 / reduce1.js
Last active July 12, 2018 04:00
Reduce example #1
const result = [0, 1, 2, 3, 4].reduce( (accum, curr) => accum + curr )
console.log('result is', result) // result is 10