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
| #include <array> | |
| #include <cmath> | |
| #include <cstdint> | |
| #include "daisy_patch.h" | |
| #include "daisysp.h" | |
| using namespace daisy; | |
| namespace |
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
| #include <array> | |
| #include <cstdint> | |
| #include "daisy_patch.h" | |
| #include "daisysp.h" | |
| using namespace daisy; | |
| namespace | |
| { |
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
| #!/usr/bin/env python | |
| # gpu_stat.py [DELAY [COUNT]] | |
| # dump some gpu stats as a line of json | |
| # {"util":{"PCIe":"0", "memory":"11", "video":"0", "graphics":"13"}, "used_mem":"161"} | |
| import json, socket, subprocess, sys, time | |
| try: | |
| delay = int(sys.argv[1]) | |
| except: | |
| delay = 1 |
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 slerp(p0, p1, n): | |
| # https://en.wikipedia.org/wiki/Slerp | |
| norm = np.linalg.norm(p0) * np.linalg.norm(p1) | |
| dot = np.sum(p0 * p1 / norm) | |
| theta_0 = np.arccos(dot) | |
| sin_theta_0 = np.sin(theta_0) | |
| interp = [] | |
| for t in np.linspace(0.0, 1.0, n): |
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
| #!/usr/bin/env python | |
| # gpu_stat.py [DELAY [COUNT]] | |
| # dump gpu stats as a line of json | |
| # {"time": 1474168378.146957, "pci_tx": 146000, "pci_rx": 1508000, | |
| # "gpu_util": 42, "mem_util": 24, "mem_used": 11710, | |
| # "temp": 76, "fan_speed": 44, "power": 65 } |
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
| #!/usr/bin/env python3 | |
| from PIL import Image | |
| import numpy as np | |
| import tensorflow as tf | |
| import tensorflow_hub as hub | |
| # smooth values from point a to point b. | |
| STEPS = 100 | |
| pt_a = np.random.normal(size=(512)) |
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
| def triplet_loss(anchor_embeddings, | |
| positive_embeddings, | |
| negative_embeddings, | |
| margin=0.0): | |
| dist_a_p = tf.norm(anchor_embeddings - positive_embeddings, axis=1) # (B) | |
| dist_a_n = tf.norm(anchor_embeddings - negative_embeddings, axis=1) # (B) | |
| constraint = dist_a_p - dist_a_n + margin # (B) | |
| per_element_hinge_loss = tf.maximum(0.0, constraint) # (B) | |
| return tf.reduce_mean(per_element_hinge_loss) |
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
| class EmbeddingModel(keras.Model): | |
| def train_step(self, data): | |
| anchors, positives = data | |
| print("a,p", anchors.shape, positives.shape) | |
| with tf.GradientTape() as tape: | |
| # Run both anchors and positives through model. | |
| anchor_embeddings = self(anchors, training=True) | |
| positive_embeddings = self(positives, training=True) |
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 rnd(*args): | |
| return np.random.random(args) |
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
| #!/usr/bin/env python3 | |
| import argparse | |
| import model as m | |
| from tensorflow.keras.callbacks import * | |
| import data as d | |
| import tensorflow as tf | |
| import os | |
| from lr_finder import LearningRateFinder |
NewerOlder