Returns a bytes_list from a string / byte.
(value)
| 25 | |
| 26 | |
| 27 | def _bytes_feature(value): |
| 28 | """Returns a bytes_list from a string / byte.""" |
| 29 | if isinstance(value, type(tf.constant(0))): |
| 30 | value = value.numpy( |
| 31 | ) # BytesList won't unpack a string from an EagerTensor. |
| 32 | value = value if isinstance(value, list) else [value] |
| 33 | return tf.train.Feature(bytes_list=tf.train.BytesList(value=value)) |
| 34 | |
| 35 | |
| 36 | def _float_feature(value): |