Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonus tf.data Assignment #9

Open
vineetm opened this issue Sep 7, 2018 · 4 comments
Open

Bonus tf.data Assignment #9

vineetm opened this issue Sep 7, 2018 · 4 comments

Comments

@vineetm
Copy link
Owner

vineetm commented Sep 7, 2018

As discussed in class, here is the bonus tf.data assignment Due Date: 14 Sep, 02 PM

Please email the notebook file(which show cell outputs) to TAs

For each sentence, return a a tuple with two entries

  1. words in the sentence
  2. characters from the first word in sentence.

This is how sample output should look like for a batch size of 2:

 array([[b'anarchism', b'is', b'a', b'political', b'philosophy', b'that',
         b'advocates', b'self-governed', b'societies', b'based', b'on',
         b'voluntary', b'institutions', b'.', b'', b'', b'', b'', b'',
         b'', b'', b'', b'', b'', b''],
        [b'these', b'are', b'often', b'described', b'as', b'stateless',
         b'societies', b',', b'although', b'several', b'authors', b'have',
         b'defined', b'them', b'more', b'specifically', b'as',
         b'institutions', b'based', b'on', b'non-hierarchical', b'or',
         b'free', b'associations', b'.']], dtype=object)>,
 <tf.Tensor: id=242, shape=(2, 9), dtype=string, numpy=
 array([[b'a', b'n', b'a', b'r', b'c', b'h', b'i', b's', b'm'],
        [b't', b'h', b'e', b's', b'e', b'', b'', b'', b'']], dtype=object)>)

Hints:

  • Hint use tf.string_split with delimiter as ''
  • tf.string_split returns sparse tensor, Use tf.sparse_tensor_to_dense to convert to a dense tensor, use default_value of UNK
  • You would need to convert the char tensor to 1D. use tf.squeeze with axis=0
@mehak126
Copy link

Can we directly use the '.values' parameter after string_split?

@vineetm
Copy link
Owner Author

vineetm commented Sep 11, 2018

@mehak126 I think you would need to convert the characters tensor to a dense tensor. But please do, give .values formulation a try too. There are many correct ways to do one thing in tensorflow!

@ankursharma-iitd
Copy link

What are the submission instructions for this assignment? Mail to the TAs?

@abhudev
Copy link

abhudev commented Sep 13, 2018

Yes, Vineet Sir has mentioned it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants