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
package amp.util.db; | |
import java.io.InputStream; | |
import java.io.Reader; | |
import java.math.BigDecimal; | |
import java.net.URL; | |
import java.sql.Array; | |
import java.sql.Blob; | |
import java.sql.Clob; | |
import java.sql.Date; |
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 random | |
earth = np.array([40.,0.,0.,0.]) | |
air = np.array([0.,40.,0.,0.]) | |
fire = np.array([0.,0.,40.,0.]) | |
water = np.array([0.,0.,0.,40.]) | |
mud = ( earth*3 + water ) / 4 | |
muck = ( earth + water*3 ) / 4 |
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 | |
from scipy.spatial.distance import cosine | |
def constant(x): | |
return x | |
# We compute the gramian matrix like so | |
def gram_matrix(x1,x2) : | |
assert( x1.shape == x2.shape ) | |
return np.matmul(np.transpose(x1),x2) / ( x1.shape[0] * x1.shape[1] ) |
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
<html> | |
<head><title>Basic Flight Calculator</title> | |
<body onload="javascript:calculateTopSpeed()"> | |
<h1>FAA Flight Calculator</h1> | |
<p>Adapted from U.S. Department of Transportation Advisory Circular (AC No. 103-7)<br> | |
Adapted from Canadian C.A.R.S. #549 Subsection B</p> | |
<style> | |
a { | |
text-decoration: none; | |
font-weight: bold; |
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
from random import random | |
from math import pow | |
ys_and_xs = [ (1, 3.8), (2, 1.9), (3, 2.9), | |
(4, 4.5), (5, 6.4), (6, 3.5), | |
(7, 6.7), (8, 6.2), (9, 8.0) ] | |
def grade(a, b): | |
error = 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
let ys_and_xs = [ [1, 3.8], [2, 1.9], [3, 2.9], | |
[4, 4.5], [5, 6.4], [6, 3.5], | |
[7, 6.7], [8, 6.2], [9, 8.0] ]; | |
function grade(a, b) { | |
let error = 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
def top_k_loss(k=25): | |
@tf.function | |
def loss(y_true, y_pred): | |
y_error_of_true = tf.keras.losses.categorical_crossentropy(y_true=y_true,y_pred=y_pred) | |
topk, indexs = tf.math.top_k( y_error_of_true, k=tf.minimum(k, y_true.shape[0]) ) | |
return topk | |
return loss |
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
class RandomCategorical(L.Layer): | |
def __init__(self, num_classes=10, factor=0.999): | |
super(RandomCategorical, self).__init__() | |
self.num_classes = num_classes | |
self.factor = factor | |
@tf.function | |
def call(self, input): | |
sample = tf.random.categorical(logits=input, num_samples=1) | |
hot = tf.reshape( tf.one_hot( sample, depth=self.num_classes ), shape=[-1,self.num_classes] ) |
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
class DenseResNet(tf.keras.layers.Layer): | |
def __init__(self, units=500, activation="tanh", kernel_initializer="glorot_uniform", layers=2): | |
super(DenseResNet, self).__init__() | |
self.layers = [tf.keras.layers.Dense(units, activation=activation, kernel_initializer=kernel_initializer) for _ in range(layers)] | |
def call(self, inputs): | |
result = inputs | |
for layer in self.layers: | |
result = layer(result) |
OlderNewer