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 wandb | |
from lightning.pytorch import LightningModule, Trainer | |
from lightning.pytorch.callbacks import ( | |
Callback, | |
) | |
from lightning.pytorch.cli import LightningArgumentParser, LightningCLI | |
import numpy as np | |
from PIL import Image as PILImage | |
import wandb |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
dolt init | |
dolt schema import --create --pks <primary_key_column> <table_name> original_data.csv | |
dolt table import -u <table_name> original_data.csv | |
dolt commit -am "initial version" | |
dolt table import -u <table_name> changed_data.csv | |
dolt diff |
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
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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 ubuntu:20.04 | |
# Set working dir | |
RUN mkdir -p /work | |
WORKDIR /work | |
ARG PYTHON_VERSION=3.9 | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt update \ |
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 ModelWeightsPrinter(Callback): | |
def __init__(self, model) -> None: | |
super().__init__() | |
self.model = model | |
def print_stats(self, hist): | |
if hist: | |
allw = np.hstack([x.flatten() for x in self.model.get_weights()]) | |
h = np.histogram(allw, bins=np.linspace(-1, 1, 5)) | |
print("weights_histogram") |
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 tensorflow as tf | |
from tensorflow import keras | |
import numpy as np | |
N = 6 | |
CLASSES = 3 | |
FEATURES = 4 | |
model = keras.Sequential([ | |
keras.layers.Dense(10, input_shape=(FEATURES,)), |
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 measure_time_tf(fun, name): | |
def time_measuring(*args): | |
start = tf.timestamp() | |
result = fun(*args) | |
end = tf.timestamp() | |
diff_times100 = 100.0 * (end - start) | |
tf.print(name, tf.cast(tf.cast(diff_times100, tf.int32), tf.float32) / 100.0) | |
return result | |
return time_measuring |
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 print_ds(ds, what): | |
def print_elems(*args): | |
tf.print(f"len of {what}", len(args), *[tf.shape(a) for a in args], args[-1]) | |
return tuple(args) | |
return ds.map(print_elems) | |
ds = print_ds(ds, "1") |
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 tensorflow as tf | |
def explain_structure(obj, how_many=3): | |
if hasattr(obj, 'shape'): | |
repr = f"{type(obj)}, {obj.shape}" | |
if type(obj) == tf.Tensor: | |
repr = f"{repr} {obj.device}" | |
return repr | |
elif type(obj) in [type([]), type(())]: | |
inner = obj |
NewerOlder