Skip to content

Instantly share code, notes, and snippets.

View kristijanbartol's full-sized avatar
🐌

Kristijan Bartol kristijanbartol

🐌
View GitHub Profile
@kristijanbartol
kristijanbartol / add_serving_metadata_tag.py
Last active November 5, 2022 17:10
Add serving metadata tag to a custom saved TensorFlow model.
import tensorflow as tf
# Saved TF model path
model_path = 'saved_model.pb'
# Directory to export new model
target_dir = 'saved_model'
with tf.gfile.FastGFile(model_path, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
@kristijanbartol
kristijanbartol / simple_custom_gradient.py
Last active May 3, 2018 15:19
Optimizing f(x)=3*x using a single parameter (the model could be therefore written as m(a)=a*x). Testing custom gradients functionality in TensorFlow.
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
import time
ZERO_TOL = 1e-8
LOSS_TOL = 1e-3
SAMPLES = 100
EPOCHS = 100000