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 torch.optim import Optimizer | |
class ADAMOptimizer(Optimizer): | |
""" | |
implements ADAM Algorithm, as a preceding step. | |
""" | |
def __init__(self, params, lr=1e-3, betas=(0.9, 0.99), eps=1e-8, weight_decay=0): | |
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay) | |
super(ADAMOptimizer, self).__init__(params, defaults) | |
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 sklearn import datasets | |
def Kmeans(X, K): | |
m = len(X) | |
X_centroid = dict() # Save which sample belong to which cluster. | |
X_centroid.fromkeys(range(0, m)) | |
C = dict() # Save cluster's cordinate | |
C.fromkeys(range(0, K)) | |
old_C = None # Cache to save old C. Used for an early termination. | |
# 1. Randomly initialize k centroids. |
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.stats import beta | |
import matplotlib.pyplot as plt | |
plt.rcParams['figure.figsize'] = [10, 7] | |
# Bell shape | |
x = np.linspace(0, 1, 10000) | |
y1 = beta.pdf(x, 2, 8) | |
y2 = beta.pdf(x, 5, 5) | |
y3 = beta.pdf(x, 8, 2) |
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 scipy.stats as stats | |
success_prob = 0.3 | |
data = np.random.binomial(n=1, p=success_prob, size=1000) # sucess is 1, failure is 0. | |
# Domain θ | |
theta_range = np.linspace(0, 1, 1000) | |
# Prior P(θ) |
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 Calibration: | |
"""Calibration matrices and utils. | |
3d XYZ are in 3D egovehicle coord. | |
2d box xy are in image coord, normalized by width and height | |
Point cloud are in egovehicle coord | |
:: | |
xy_image = K * [R|T] * xyz_ego |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
export function lint(response) { | |
const lintIssues = []; | |
let isLabelable = true; | |
if (response.values) { | |
for (const value of response.values) { | |
if (value.field_id === 'invoice_labeling' && !value.selected.includes('yes')) { | |
isLabelable = false; | |
} | |
} | |
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
const REGEX_ISO_CURRENCY_CODE = /[A-Z]{3}/; | |
const labelsToCheck = ['Invoice Total', 'Invoice Amount Due', 'Item Amount', 'Unit Price']; | |
export function lint(response) { | |
const lintIssues = []; | |
if (response.annotations) { | |
for (const annotation of response.annotations) { | |
if (labelsToCheck.includes(annotation.label)) { |
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
const REGEX_no_dollar_sign = /[!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/; | |
const labelsToCheck = ['Invoice Total', 'Invoice Amount Due', 'Item Amount', 'Unit Price']; | |
export function lint(response) { | |
const lintIssues = []; | |
if (response.annotations) { | |
for (const annotation of response.annotations) { | |
if (labelsToCheck.includes(annotation.label)) { |
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
const REGEX_contains_hashtag = /[#]/; | |
const labelsToCheck = ['Invoice Number']; | |
export function lint(response) { | |
const lintIssues = []; | |
if (response.annotations) { | |
for (const annotation of response.annotations) { | |
if (labelsToCheck.includes(annotation.label)) { |
OlderNewer