MCPcopy Create free account
hub / github.com/tensorflow/models / decode

Method decode

official/projects/yt8m/dataloaders/yt8m_input.py:312–330  ·  view source on GitHub ↗

Parses a single tf.train.SequenceExample into video and label tensors.

(self,
             serialized_example: tf.train.SequenceExample)

Source from the content-addressed store, hash-verified

310 {self._label_field: tf.io.VarLenFeature(tf.int64)})
311
312 def decode(self,
313 serialized_example: tf.train.SequenceExample) -> Dict[str, Any]:
314 """Parses a single tf.train.SequenceExample into video and label tensors."""
315 contexts, features = tf.io.parse_single_sequence_example(
316 serialized_example,
317 context_features=self._context_features,
318 sequence_features=self._sequence_features)
319 decoded_tensor = {**contexts, **features}
320 for i, name in enumerate(self._feature_names):
321 # Convert the VarLen feature to dense tensor.
322 if self._feature_from_bytes[i]:
323 dtype = tf.dtypes.as_dtype(self._feature_dtypes[i])
324 decoded_tensor[name] = tf.cast(
325 tf.io.decode_raw(decoded_tensor[name], out_type=dtype), tf.float32
326 )
327 else:
328 if isinstance(decoded_tensor[name], tf.SparseTensor):
329 decoded_tensor[name] = tf.sparse.to_dense(decoded_tensor[name])
330 return decoded_tensor
331
332
333class Parser(parser.Parser):

Callers 10

test_decoderMethod · 0.95
test_parserMethod · 0.95
predictFunction · 0.45
evaluateFunction · 0.45
find_answer_spansFunction · 0.45
realign_answer_spanFunction · 0.45
processMethod · 0.45
execute_commandFunction · 0.45

Calls

no outgoing calls

Tested by 3

test_decoderMethod · 0.76
test_parserMethod · 0.76