Skip to content

Instantly share code, notes, and snippets.

View namyunz's full-sized avatar

Namyun Kim namyunz

  • Seoul, South Korea
View GitHub Profile
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
# Define custom py_func which takes also a grad op as argument:
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
# Need to generate a unique name to avoid duplicates:
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))
FBLiker