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 cc.openhome; | |
import java.util.Arrays; | |
interface List { | |
default Integer head() { return null; } | |
default List tail() { return null; } | |
Integer sum(); | |
// 實現模式比對 |
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 cc.openhome; | |
import java.util.Arrays; | |
sealed interface List<T> permits Nil, Cons<T> { | |
default T head() { return null; } | |
default List<T> tail() { return null; } | |
} | |
final class Nil implements List { |
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 torch | |
import cv2 | |
import matplotlib.pyplot as plt | |
def training_loop(epochs, lr, params, x, y, verbose = False): | |
mx = torch.unsqueeze(x, 1).float() | |
my = torch.unsqueeze(y, 1).float() | |
model = torch.nn.Linear(mx.size(1), my.size(1)) | |
mse_loss = torch.nn.MSELoss() |
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 torch | |
import cv2 | |
import matplotlib.pyplot as plt | |
def model(x, w, b): | |
return w * x + b | |
def mse_loss(p, y): | |
return ((p - y) ** 2).mean() |
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 torch | |
import cv2 | |
import matplotlib.pyplot as plt | |
def model(x, w, b): | |
return w * x + b | |
def mse_loss(p, y): | |
return ((p - y) ** 2).mean() |
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 torch | |
import cv2 | |
import matplotlib.pyplot as plt | |
def model(x, w, b): | |
return w * x + b | |
def mse_loss(p, y): | |
return ((p - y) ** 2).mean() |
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 cv2 | |
import matplotlib.pyplot as plt | |
def model(x, w, b): | |
return w * x + b | |
def mse_loss(p, y): | |
return ((p - y) ** 2).mean() | |
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 cv2 | |
import matplotlib.pyplot as plt | |
def model(x, w, b): | |
return w * x + b | |
def mse_loss(p, y): | |
return ((p - y) ** 2).mean() |
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 matplotlib.pyplot as plt | |
# 雙抛物面公式 | |
def f(x, y): | |
return x ** 2 / 4 - y ** 2 / 4 | |
# https://openhome.cc/Gossip/DCHardWay/ab.csv | |
data = np.loadtxt('ab.csv', delimiter=',') |
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 matplotlib.pyplot as plt | |
# https://openhome.cc/Gossip/DCHardWay/ab.csv | |
data = np.loadtxt('ab.csv', delimiter=',') | |
a = data[:,0] | |
b = data[:,1] | |
label = data[:,2] |