in Education by
I'm using TensorFlow Alpha 2.0. I have TFRecords files I'm reading from, each one holding a short video clip with each frame encoded as jpeg byte string to save space: { 'numframes': tf.io.FixedLenFeature([], tf.int64), 'frames': tf.io.VarLenFeature(tf.string) } I have a map step in my tf.data.Dataset pipeline that successfully parses each example: def parse_tfrecord(p): return tf.io.parse_single_example(p, example_schema) My next step is to read out the number of frames from numframes and run the tf.io.decode_jpeg function on each frame in frames.values[i] with i being from range(numframes): def parse_jpegs(p): numframes = p['numframes'] return tf.map_fn(tf.io.decode_jpeg, [p['frames'].values[i] for i in range(numframes)]) My dataset pipeline for completeness: def dataset(): dataset = tf.data.Dataset.list_files("*.tfrecord") dataset = tf.data.TFRecordDataset(dataset) dataset = dataset.shuffle(1000).repeat() dataset = dataset.map(parse_tfrecord) dataset = dataset.map(parse_jpegs) return dataset If I exclude the dataset.map(parse_jpegs) line it all works alright, showing me something like {'frames': , 'numframes': } (Note that the numframes tensor includes a numpy value of 25. I can get that outside my dataset pipeline with the tensor.numpy() method) Within that map function though, I can't call .numpy() to get the value out of the tensor, and when printing the tensor itself it hasn't been evaluated or something because there is no value shown yet. What is the best way to parse all these frames within the dataset pipeline? EDIT: Error message I'm getting is TypeError: 'Tensor' object cannot be interpreted as an integer in parse_jpegs when trying to get numframes. This makes sense to me why a tensor can't be interpreted as an int, but how can I get the value from that tensor to use to set the range? The problem I'm running into comes down to the fact that each "frames" object has a different number of frames. If I can apply tf.io.decode_jpeg to each frame in that list without needing to record number of frames separately I would be fine with that, but I have "numframes" here so I know how many frames need to be decoded in my "frames" list. EDIT: I'll heave the question up for anyone else who might find it helpful, but I ended up just returning the raw bytestrings and doing the decode_jpeg in a separate generator function outside the dataset API. It was much easier that way, even if it might be slower. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In my specific case, I ended up finding out that map_fn was trying to turn my input tensor into an output tensor of the same type. In this case, tf.io.decode_jpeg takes in a string (of bytes) and outputs a uint8 array, which was causing problems. Another argument to tf.map_fn(... output_type=tf.uint8) seems to have fixed it for me! Maybe not exactly as written since I continued tinkering with it since asking the question, but I got it working now.

Related questions

0 votes
    I have an XML with Text elements that can include tagged text and depending on the elements attribute value ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Visual Studio 2005 .Net Framework 2.0 I have the AjaxControlToolkit within my web application bin folder ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I write the following code to access the page but this is not working for me if (User.Identity. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I write the following code to access the page but this is not working for me if (User.Identity. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    In my XSLT stylesheet I extract the value of the current month using a month-from-dateTime like this . ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I've created a seperate assembly with a class that is intended to be published through wmi. Then I' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have an XSLT like this: In the second template, which matches nodes in the fooDocument.xml which is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have an XSLT like this: In the second template, which matches nodes in the fooDocument.xml which is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have an XML and would like to : sort on employeeNumber, and for each bookingtime by year, month ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    I have a problem with Spring and JPA. Basically I try to use JPA with Spring with a pure approach ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to access my .xml file in the ClientBin with no success. code: WebClient xmlClient = ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    In the chapter seven of this book "TensorFlow Machine Learning Cookbook" the author in pre-processing data ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    In the tensorflow documentation at the autograph section we have the following code snippet @tf.function def train ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
...