Skip to content

Instantly share code, notes, and snippets.

View Nov05's full-sized avatar
💭
Homo Sapiens

Nov05

💭
Homo Sapiens
View GitHub Profile
@Nov05
Nov05 / model.py
Last active March 11, 2020 04:33
2020-03-07 CNN-LSTM image captioning
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
class EncoderCNN(nn.Module):
def __init__(self, embed_size):
# super(EncoderCNN, self).__init__()
super().__init__()

Find the elements that appear in both lists.

import time
with open('names_1.txt', 'r') as f:
    names_1 = f.read().split("\n")  # List containing 10000 names
with open('names_2.txt', 'r') as f:
    names_2 = f.read().split("\n")  # List containing 10000 names
@Nov05
Nov05 / json_to_csv.py
Created December 5, 2019 12:27 — forked from emredjan/json_to_csv.py
Yelp Dataset Challenge JSON to CSV conversion
'''
Load Yelp JSON files and spit out CSV files
Does not try to reinvent the wheel and uses pandas json_normalize
Kinda hacky and requires a bit of RAM. But works, albeit naively.
Tested with Yelp JSON files in dataset challenge round 12:
https://www.yelp.com/dataset/challenge
'''
import json

Baseline

# baseline score
X_train, X_val, y_train, y_val = train_test_split(
    X_trainval, y_trainval, test_size=0.33, random_state=42)
print("train mean velocity:", y_train.mean())
y_val_pred = [y_train.mean()] * len(y_val)
print('baseline error score:', mean_squared_error(y_val, y_val_pred))
!pip install colorlover
# Successfully installed colorlover-0.3.0
import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import seaborn as sns
import pandas_profiling
import plotly
import plotly.graph_objects as go
from sklearn.preprocessing import MinMaxScaler
@Nov05
Nov05 / selenium.py
Created July 4, 2019 06:29 — forked from korakot/selenium.py
Use selenium in Colab
# install chromium, its driver, and selenium
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')