This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(230400,SERIAL_8N1); | |
Serial1.begin(230400, SERIAL_8N1, 21, 22); | |
} | |
int n; | |
void loop() { | |
n = Serial1.available(); | |
if (n != 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from argparse import ArgumentParser | |
def convert(input_file, output_file): | |
with open(input_file, 'r') as fin: | |
data2 = json.load(fin) | |
features = data2['features'] | |
with open(output_file, 'w') as fout: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import torch | |
import torchvision | |
from torch.utils.data import DataLoader | |
from torchvision.transforms import ToTensor | |
train_dataset = torchvision.datasets.MNIST('data', train=True, transform=ToTensor(), download=True) | |
test_dataset = torchvision.datasets.MNIST('data', train=False, transform=ToTensor(), download=True) | |
batch_size = 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
w = torch.tensor([5.], requires_grad=True) | |
lr = 0.6 | |
w_mom_grad = 0 | |
momentum_coef = 0.9 | |
weight_decay = 0.001 | |
for i in range(10): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
x = torch.tensor([1.5,2.8,15.,19.5]) | |
y = torch.tensor([0.,0.,1.,1.]) | |
w = torch.tensor([-.3], requires_grad=True) | |
b = torch.tensor([0.1232154], requires_grad=True) | |
def model(x): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import av | |
import tqdm | |
from av.video import VideoStream | |
desired_fps = 2 | |
timestamp = int(time.time()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client | |
# put the line below to disable tunneling outcoming trafic | |
route-nopull | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
train_ds = tf.keras.utils.image_dataset_from_directory( | |
train_dir, | |
validation_split=0.1, | |
subset="training", | |
label_mode="categorical", | |
#shuffle=True, | |
seed=123, | |
image_size=(image_size, image_size), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras.backend as K | |
def f1(y_true, y_pred): | |
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) | |
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) | |
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1))) | |
precision = true_positives / (predicted_positives + K.epsilon()) | |
recall = true_positives / (possible_positives + K.epsilon()) | |
f1_val = 2*(precision*recall)/(precision+recall+K.epsilon()) | |
return f1_val | |
NewerOlder