mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 06:54:44 +00:00
Update titanlearn.py
This commit is contained in:
parent
69ef08bfd4
commit
9fb53f4297
@ -30,9 +30,10 @@ from sklearn import metrics, datasets
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import math
|
import math
|
||||||
|
import time
|
||||||
|
|
||||||
#enable CUDA if possible
|
#enable CUDA if possible
|
||||||
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
device = torch.device("cpu")
|
||||||
|
|
||||||
#linear_nn: creates a fully connected network given params
|
#linear_nn: creates a fully connected network given params
|
||||||
def linear_nn(in_dim, hidden_dim, out_dim, num_hidden, act_fn="tanh", end="none"):
|
def linear_nn(in_dim, hidden_dim, out_dim, num_hidden, act_fn="tanh", end="none"):
|
||||||
@ -194,8 +195,12 @@ def retyuoipufdyu():
|
|||||||
|
|
||||||
data = torch.tensor(datasets.fetch_california_housing()['data']).to(torch.float)
|
data = torch.tensor(datasets.fetch_california_housing()['data']).to(torch.float)
|
||||||
ground = datasets.fetch_california_housing()['target']
|
ground = datasets.fetch_california_housing()['target']
|
||||||
ground=torch.tensor(ground).to(torch.float)
|
ground = torch.tensor(ground).to(torch.float)
|
||||||
model = linear_nn(8, 100, 1, 20, act_fn = "relu")
|
model = linear_nn(8, 100, 1, 20, act_fn = "relu")
|
||||||
print(model)
|
print(model)
|
||||||
return train_sgd_simple(model,"regression", data, ground, learnrate=1e-4, iters=1000)
|
return train_sgd_simple(model,"regression", data, ground, learnrate=1e-4, iters=1000)
|
||||||
#retyuoipufdyu()
|
|
||||||
|
start = time.time()
|
||||||
|
retyuoipufdyu()
|
||||||
|
end = time.time()
|
||||||
|
print(end-start)
|
||||||
|
Loading…
Reference in New Issue
Block a user