Skip to content

Instantly share code, notes, and snippets.

View mtrencseni's full-sized avatar

Marton Trencseni mtrencseni

  • Dubai
View GitHub Profile
@mtrencseni
mtrencseni / Maro Newsletter #10.md
Last active August 29, 2015 14:02
Maro Newsletter #10
@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,
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)
Δ = torch.matmul(A, x) - b
L = torch.norm(Δ, p=2)
L.backward()
x.data -= step_size * x.grad.data
stop_loss = 1e-2
step_size = stop_loss / 3.0
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