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
prompt = """ | |
Input: Print the current directory | |
Output: pwd | |
Input: List files | |
Output: ls -l | |
Input: Change directory to /tmp | |
Output: cd /tmp |
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
plt.figure(figsize=(10,6)) | |
sns.kdeplot(probs_lgr, label='Logistic regression') | |
sns.kdeplot(preds_svc, label='SVM') | |
plt.title("Probability Density Plot for 2 Classifiers") | |
plt.show() |
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
strategy = tf.distribute.MirroredStrategy() | |
BATCH_SIZE = 64 | |
GLOBAL_BATCH_SIZE = BATCH_SIZE * strategy.num_replicas_in_sync | |
train_data = tf.data.Dataset(...).batch(GLOBAL_BATCH_SIZE) | |
with strategy.scope(): | |
model = tf.keras.Sequential(...) | |
model.compile(...) |
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
BATCH_SIZE = 64 | |
train_data = tf.data.Dataset(...).batch(BATCH_SIZE) | |
model = tf.keras.Sequential(...) | |
model.compile(...) | |
model.fit(train_data, epochs=4) |
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
class MyModel(keras.Model): | |
def train_step(self, data): | |
# Get the data batch | |
inputs, targets = data | |
# Get the model's weights | |
trainable_vars = self.trainable_variables | |
# Forward pass | |
with tf.GradientTape() as tape: | |
# Get the predictions | |
preds = self(inputs, training=True) |
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 torchvision.models as models | |
import torchvision.transforms as transforms | |
from PIL import Image | |
img = Image.open("test/assets/encode_jpeg/grace_hopper_517x606.jpg") | |
# Step 1: Load a pre-trained model. |
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
from PIL import Image | |
from torchvision.prototype import models as pm | |
img = Image.open("test/assets/encode_jpeg/grace_hopper_517x606.jpg") | |
# Step 1: Load a pre-trained model. | |
# In this step we will load a ResNet architecture. | |
weights = pm.ResNet50_Weights.ImageNet1K_V1 | |
model = pm.resnet50(weights=weights) |
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
FROM <base.Dockerfile:tag> | |
# Install Tensorflow | |
RUN pip3 install tensorflow | |
# Install PyTorch | |
RUN pip3 install torch==1.5.1 torchvision==0.6.1 | |
# Create and configure NB_USER user with UID=1000 and in the 'users' group | |
# but allow for non-initial launches of the notebook to have | |
# $HOME provided by the contents of a PV |
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
ARG CUDA=10.1 | |
ARG UBUNTU_VERSION=18.04 | |
FROM nvidia/cuda:${CUDA}-base-ubuntu${UBUNTU_VERSION} as base | |
# ARCH and CUDA are specified again because the FROM directive resets ARGs | |
# (but their default value is retained if set previously) | |
ARG CUDA | |
ARG CUDNN=7.6.4.38-1 | |
ARG CUDNN_MAJOR_VERSION=7 |
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 ctypes | |
import pathlib | |
if __name__ == "__main__": | |
# load the lib | |
libname = pathlib.Path().absolute() / "libcadd.so" | |
c_lib = ctypes.CDLL(libname) | |
x, y = 6, 2.3 |
NewerOlder