Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132926 views
License: OTHER
1
import os
2
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
3
import tensorflow as tf
4
5
def huber_loss(labels, predictions, delta=1.0):
6
residual = tf.abs(predictions - labels)
7
def f1(): return 0.5 * tf.square(residual)
8
def f2(): return delta * residual - 0.5 * tf.square(delta)
9
return tf.cond(residual < delta, f1, f2)
10
11
def make_dir(path):
12
""" Create a directory if there isn't one already. """
13
try:
14
os.mkdir(path)
15
except OSError:
16
pass
17