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
#!/bin/bash | |
# Check if the input parameters are provided | |
if [ $# -ne 2 ]; then | |
echo "Usage: $0 <date> <number>" | |
exit 1 | |
fi | |
date_input="$1" | |
number="$2" |
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
epoch = 100 | |
for _ in range(epoch): | |
for i in range(len(X)): | |
x, y = torch.tensor(X[i]), torch.tensor(Y[i]) | |
y_predict = model(x) | |
loss_tensor = loss(y_predict, y) | |
loss_tensor.backward() | |
loss_value = loss_tensor.data[0] | |
with torch.no_grad(): |
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
%pip install torchviz==0.0.2 | |
# one iteration | |
x = X[0] | |
y = Y[0] | |
y_predicted = model(x) | |
loss_tensor = loss(y_predicted, y) | |
loss_value = loss_tensor.data[0] | |
print(f"x: {x}, actual y: {y}, predicted y: {y}, loss: {loss_value}") | |
print(f"w: {w.data[0]}, b: {w.data[0]}") |
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
def loss(y_predict, y_actual): | |
return torch.pow(y_predict - y_actual, 2) |
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 | |
torch.manual_seed(2021) | |
w = torch.rand(1, requires_grad=True, dtype=torch.float64) | |
b = torch.rand(1, requires_grad=True, dtype=torch.float64) | |
def model(X): | |
return X * w + b |
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 | |
def f(x): | |
return x * 2 + 1 | |
rng = np.random.default_rng(2021) | |
X = rng.random(1000) | |
Y = [f(x) for x in X] |
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
# see list of containers: https://github.com/JetBrains/projector-docker | |
FROM registry.jetbrains.team/p/prj/containers/projector-idea-c:latest | |
ENV ORG_JETBRAINS_PROJECTOR_SERVER_PORT="8080" | |
EXPOSE 8080 |
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
export CONTAINER_URI="gcr.io/deeplearning-platform-release/experimental.theia.1-7" | |
export INSTANCE_NAME=... | |
export PROJECT_NAME=... | |
export IMAGE_PROJECT="deeplearning-platform-release" | |
export IMAGE_FAMILY="theia-container-experimental" | |
export MACHINE_TYPE=... #"n1-standard-4" | |
export ZONE=.... #"us-central1-a" | |
gcloud notebooks instances create "${INSTANCE_NAME}" \ | |
--project="${PROJECT_NAME}" \ | |
--location="${ZONE}" \ |
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
export CONTAINER_URI="gcr.io/deeplearning-platform-release/experimental.theia.1-7" | |
export INSTANCE_NAME=... | |
export PROJECT_NAME=... | |
export IMAGE_PROJECT="deeplearning-platform-release" | |
export IMAGE_FAMILY="theia-container-experimental" | |
export MACHINE_TYPE=... #"n1-standard-4" | |
export ZONE=... #"us-central1-a" | |
gcloud compute instances create "${INSTANCE_NAME}" \ | |
--project="${PROJECT_NAME}" \ | |
--zone="${ZONE}" \ |
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
INSTANCE_NAME=$1 | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "sudo rm -rf /home/jupyter/jupyterlab-gcloud-auth" | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "mkdir -p /home/jupyter/jupyterlab-gcloud-auth" | |
gcloud compute scp --recurse ./* "jupyter@${INSTANCE_NAME}:/home/jupyter/jupyterlab-gcloud-auth" | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "pip uninstall -y jupyterlab_gcloud_auth" | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "pip install /home/jupyter/jupyterlab-gcloud-auth" | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "sudo service jupyter restart" | |
gcloud compute ssh "jupyter@${INSTANCE_NAME}" -- "cd /home/jupyter/jupyterlab-gcloud-auth && jupyter labextension install" |
NewerOlder