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
#!/usr/bin/env bash | |
# | |
# 首先,请安装 llvm 套件 | |
# 查看: https://apt.llvm.org/ | |
# 例如 ubuntu 22.04, 执行: | |
# wget https://apt.llvm.org/llvm.sh | |
# 查看文件 llmv.sh 内容, 看到稳定版是 19 | |
# 执行安装: | |
# chmod +x llvm.sh | |
# sudo ./llvm.sh all |
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 math | |
def sin(x): | |
if isinstance(x, Dual): | |
return Dual(sin(x.x), cos(x.x) * x.dx) | |
return math.sin(x) | |
def cos(x): | |
if isinstance(x, Dual): | |
return Dual(cos(x.x), -1 * sin(x.x) * x.dx) |
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 sklearn.datasets import load_iris | |
def softmax(inputs): | |
return np.exp(inputs) / np.sum(np.exp(inputs), 1)[:, None] | |
def construct_net(in_dim, out_dim, hidden_dim=20): | |
bound1 = np.sqrt(6.0 / (in_dim + hidden_dim)) |