Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Manuel Romero mrm8488

🏠
Working from home
View GitHub Profile
View train_LM_from_scratch_DS_with_nlp.py
class NlpRawTextDataset(Dataset):
def __init__(self, tokenizer, file_path: str, block_size: int):
self.tokenizer = tokenizer
self.file_path = file_path
self.block_size = block_size
print("Loading Dataset...")
self.dataset = load_dataset("text", data_files=file_path)["train"]
print("Loaded Dataset!")
View testN.js
function shallowEqual(obj1, obj2) {
const keys1 = Object.keys(obj1);
if (keys1.length ==
Object.keys(obj2).length) return
false;
for (const k1 of keys1) {
if (!(k1 in obj2)) return false;
if (obj1[k1] !== obj2[k1]) return
false;
}
View gesirtasf.py
(XJ Bs
wget -0 translation.py
Ig NGL
7 ; PE TE Da MAR a SERS |
View GCP_BUCKET_TO_COLAB.md

How to download files from a GCP Bucket to Colab 📚📝

  1. Go to your bucket dashboard

  2. Click on the bucket where is stored the resource you want to download

  3. Go to Permissions tab

  4. Add a new member with the gmail account your are going to use in your Colab

  5. Give to this member the required permissions (Admin, List, Create,...)

    5.b. Admin permissions will work!

  6. In your Colab Notebook, execute the following commands:

@mrm8488
mrm8488 / compare_js_objects.js
Created Apr 30, 2020
Vanilla COMPARE JS OBJECTS
View compare_js_objects.js
const compareObjects = (a, b) => {
if (a === b) return true;
if (typeof a != 'object' || typeof b != 'object' || a == null || b == null) return false;
let keysA = Object.keys(a), keysB = Object.keys(b);
if (keysA.length != keysB.length) return false;
for (let key of keysA) {
@mrm8488
mrm8488 / text_dataset_pytorch.py
Created Apr 17, 2020
Create an efficient text dataset
View text_dataset_pytorch.py
class LazyTextDataset(Dataset):
def __init__(self, filename):
self._filename = filename
self._total_data = 0
self._total_data = int(subprocess.check_output("wc -l " + filename, shell=True).split()[0])
def __getitem__(self, idx):
line = linecache.getline(self._filename, idx + 1)
csv_line = csv.reader([line])
return next(csv_line)
View install_conda_google_colab.txt
"################################################################################\n",
"# INSTALL CONDA ON GOOGLE COLAB\n",
"################################################################################\n",
"! wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh\n",
"! chmod +x Miniconda3-py37_4.8.2-Linux-x86_64.sh\n",
"! bash ./Miniconda3-py37_4.8.2-Linux-x86_64.sh -b -f -p /usr/local\n",
"import sys\n",
"sys.path.append('/usr/local/lib/python3.7/site-packages/')"
View smallberta_pretraining.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View smallberta_pretraining.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View hypercropz.py
from tkinter import *
from PIL import ImageTk,Image
import time
import os
targetImageWidth = 850
targetImageHeight = 400
inputImageWidth = 0
inputImageHeight = 0
You can’t perform that action at this time.