Skip to content

Instantly share code, notes, and snippets.

View mtrencseni's full-sized avatar

Marton Trencseni mtrencseni

  • Dubai
View GitHub Profile
# regex pattern: [\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,6}
# equivalent rxe code:
username = rxe.one_or_more(rxe.set([rxe.alphanumeric(), '.', '%', '+', '-']))
domain = (rxe
.one_or_more(rxe.set([rxe.alphanumeric(), '.', '-']))
.literal('.')
.at_least_at_most(2, 6, rxe.set([rxe.range('a', 'z'), rxe.range('A', 'Z')]))
)
email = (rxe
torch.set_default_tensor_type('torch.cuda.FloatTensor')
import torch
dim = 2
A = torch.rand(dim, dim, requires_grad=False)
b = torch.rand(dim, 1, requires_grad=False)
x = torch.autograd.Variable(torch.rand(dim, 1), requires_grad=True)
stop_loss = 1e-2
step_size = stop_loss / 3.0
print('Loss before: %s' % (torch.norm(torch.matmul(A, x) - b)))
for i in range(1000*1000):
Δ = torch.matmul(A, x) - b
stop_loss = 1e-2
step_size = stop_loss / 3.0
x.data -= step_size * x.grad.data
L.backward()
Δ = torch.matmul(A, x) - b
L = torch.norm(Δ, p=2)
import torch
dim = 2
A = torch.rand(dim, dim, requires_grad=False)
b = torch.rand(dim, 1, requires_grad=False)
x = torch.autograd.Variable(torch.rand(dim, 1), requires_grad=True)
@mtrencseni
mtrencseni / growth_accounting.py
Last active May 21, 2022 05:49
Airflow Growth Accounting Framework
from airflow import DAG
from lib.dag_presto_ds_insert import dag_presto_ds_insert
from airflow.operators import PrestoOperator, DsPartitionSensor
from datetime import date, datetime, timedelta
def dag_growth_accounting(
base_table_name,
start_date,
events_table,
days=1,