Skip to content

Instantly share code, notes, and snippets.

View JonathanLoscalzo's full-sized avatar

Jonathan Loscalzo JonathanLoscalzo

View GitHub Profile
@JonathanLoscalzo
JonathanLoscalzo / demo.py
Created October 29, 2019 15:03 — forked from joelthchao/demo.py
Keras uses TensorBoard Callback with train_on_batch
import numpy as np
import tensorflow as tf
from keras.callbacks import TensorBoard
from keras.layers import Input, Dense
from keras.models import Model
def write_log(callback, names, logs, batch_no):
for name, value in zip(names, logs):
summary = tf.Summary()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JonathanLoscalzo
JonathanLoscalzo / 01-directory-structure.md
Created April 29, 2020 19:31 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@JonathanLoscalzo
JonathanLoscalzo / custom_data_loader.py
Created June 4, 2020 17:13 — forked from ikhlestov/custom_data_loader.py
pytorch: custom data loader
import torch
import torchvision as tv
class ImagesDataset(torch.utils.data.Dataset):
def __init__(self, df, transform=None,
loader=tv.datasets.folder.default_loader):
self.df = df
self.transform = transform
self.loader = loader
@JonathanLoscalzo
JonathanLoscalzo / architecture_pattern.py
Created June 4, 2020 17:14 — forked from ikhlestov/architecture_pattern.py
pytorch: architecture pattern
class ImagesDataset(torch.utils.data.Dataset):
pass
class Net(nn.Module):
pass
model = Net()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
scheduler = lr_scheduler.StepLR(optimizer, step_size=30, gamma=0.1)
criterion = torch.nn.MSELoss()
@JonathanLoscalzo
JonathanLoscalzo / imagenet1000_clsidx_to_labels.json
Last active June 5, 2020 20:35 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{
0: "tench, Tinca tinca",
1: "goldfish, Carassius auratus",
2: "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",
3: "tiger shark, Galeocerdo cuvieri",
4: "hammerhead, hammerhead shark",
5: "electric ray, crampfish, numbfish, torpedo",
6: "stingray",
7: "cock",
8: "hen",
@JonathanLoscalzo
JonathanLoscalzo / stratified_sample.py
Created June 15, 2020 04:13 — forked from srikarplus/stratified_sample.py
Stratified Sampling in Pytorch
def make_weights_for_balanced_classes(images, nclasses):
count = [0] * nclasses
for item in images:
count[item[1]] += 1
weight_per_class = [0.] * nclasses
N = float(sum(count))
for i in range(nclasses):
weight_per_class[i] = N/float(count[i])
weight = [0] * len(images)
for idx, val in enumerate(images):
@JonathanLoscalzo
JonathanLoscalzo / register-jupyter-env
Created June 23, 2020 22:29 — forked from thvitt/register-jupyter-env
Register a jupyter kernel for the current pyenv.
#!/bin/sh
if [ "$PYENV_VERSION" -ne "" ]
then
name=`pyenv version-name`
python=`pyenv which python`
else
name=`basename "$VIRTUAL_ENV"`
python="$VIRTUALENV/bin/python"
fi
@JonathanLoscalzo
JonathanLoscalzo / tick-compose.yml
Created July 20, 2020 18:19 — forked from stefanotroia/tick-compose.yml
TICK docker compose
version: '3'
services:
influxdb:
image: 'influxdb:latest'
container_name: influxDB
networks:
- tick-network
volumes:
- '/home/tick/influxdb/data:/var/lib/influxdb'
- '/home/tick/influxdb/config/:/etc/influxdb/'

Create a new project

poetry new <project-name>

Add a new lib

potry add <library>

Remove a lib