This file contains hidden or 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 asyncio | |
import base64 | |
import json | |
import os | |
import pyaudio | |
from websockets.asyncio.client import connect | |
class SimpleGeminiVoice: | |
def __init__(self): |
This file contains hidden or 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
from __future__ import print_function | |
import numpy as np | |
def hessianChecking(grad, hessian, w, *args): | |
N = w.shape[0] | |
H = hessian(w, *args) | |
numericalHessian = np.zeros_like(H) | |
# check symmetry of Hessian first |
This file contains hidden or 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
function softmax_grad_demo_hw() | |
% softmax_grad_demo_hw - when complete reproduces Figure 4.3 from Chapter 4 | |
% of the text | |
%%% load data | |
[X,y] = load_data(); | |
%%% run gradient descent | |
w = softmax_gradient_descent(X,y); |
This file contains hidden or 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
% OSX | |
cat /dev/cu.usbmodem1421 | gawk '{x="'"`gdate +%s%3N`"'"; printf "%s,%s\n",x,$0 }' | tee data.csv | |
% Ubuntu | |
cat /dev/cu.usbmodem1421 | awk '{x="'"`date +%s%3N`"'"; printf "%s,%s\n",x,$0 }' | tee data.csv |
This file contains hidden or 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
/* | |
* Clock.c | |
* | |
* Created: 5/25/2016 1:01:13 AM | |
* Author : andrey | |
*/ | |
#define F_CPU 1000000UL | |
#include <avr/io.h> | |
#include <util/delay.h> |
This file contains hidden or 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
# Kadane's algorithm | |
def largest(a): | |
max_current = -100 | |
maxvalue = -100 | |
for i in range(len(a)): | |
if (max_current < 0): | |
max_current = a[i] | |
currenti = i | |
currentj = i |
This file contains hidden or 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"net" | |
"os" | |
"strconv" | |
"strings" | |
) |
This file contains hidden or 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 | |
def integral(mask): | |
""" | |
calculate integral image for quick histogram | |
""" | |
assert(mask.dtype == bool) | |
M, N = mask.shape | |
integral = np.zeros((M + 1, N + 1)).astype(int) |
This file contains hidden or 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
compatible = 0 | |
N = len(s1) | |
for i in range(N): | |
for j in range(i + 1, N): | |
if (s1[i] == s1[i] and s2[i] == s2[j]) or (s1[i] != s1[j] and s2[i] != s2[j]): | |
compatible += 1 | |
return compatible/(N*(N - 1)/2) |