Jeremy Lewi
Jeremy Lewi

Reputation: 6776

How can I decode base64 data in TensorFlow?

Is it possible to decode base64 data in TensorFlow?

I looked in the documentation but didn't see any ops.

Upvotes: 0

Views: 807

Answers (1)

keveman
keveman

Reputation: 8487

How about something like :

import base64

def base64_decode_op(x):
  return tf.py_func(lambda x: base64.decodestring(x), [x], [tf.string])[0]

sess = tf.InteractiveSession()
a = base64.encodestring("abcd")
base64_decode_op(a).eval()
# prints 'abcd'

Upvotes: 1

Related Questions