Demonstrate Seq2Seq Wrapper with twitter chat log


In [1]:
import tensorflow as tf
import numpy as np

# preprocessed data
from datasets.twitter import data
import data_utils

In [2]:
# load data from pickle and npy files
metadata, idx_q, idx_a = data.load_data(PATH='datasets/twitter/')
(trainX, trainY), (testX, testY), (validX, validY) = data_utils.split_dataset(idx_q, idx_a)

In [3]:
# parameters 
xseq_len = trainX.shape[-1]
yseq_len = trainY.shape[-1]
batch_size = 16
xvocab_size = len(metadata['idx2w'])  
yvocab_size = xvocab_size
emb_dim = 1024

In [4]:
import seq2seq_wrapper

In [6]:
import importlib
importlib.reload(seq2seq_wrapper)


Out[6]:
<module 'seq2seq_wrapper' from '/home/suriya/_/tf/tf-seq2seq-wrapper/seq2seq_wrapper.py'>

In [5]:
model = seq2seq_wrapper.Seq2Seq(xseq_len=xseq_len,
                               yseq_len=yseq_len,
                               xvocab_size=xvocab_size,
                               yvocab_size=yvocab_size,
                               ckpt_path='ckpt/twitter/',
                               emb_dim=emb_dim,
                               num_layers=3
                               )


<log> Building Graph </log>

In [6]:
val_batch_gen = data_utils.rand_batch_gen(validX, validY, 256)
test_batch_gen = data_utils.rand_batch_gen(testX, testY, 256)
train_batch_gen = data_utils.rand_batch_gen(trainX, trainY, batch_size)

In [9]:
sess = model.train(train_batch_gen, val_batch_gen)


<log> Training started </log>

Model saved to disk at iteration #500
val   loss : 3.370399
Interrupted by user at iteration 565

In [7]:
sess = model.restore_last_session()

In [10]:
input_ = test_batch_gen.__next__()[0]
output = model.predict(sess, input_)
print(output.shape)


(256, 20)

In [11]:
replies = []
for ii, oi in zip(input_.T, output):
    q = data_utils.decode(sequence=ii, lookup=metadata['idx2w'], separator=' ')
    decoded = data_utils.decode(sequence=oi, lookup=metadata['idx2w'], separator=' ').split(' ')
    if decoded.count('unk') == 0:
        if decoded not in replies:
            print('q : [{0}]; a : [{1}]'.format(q, ' '.join(decoded)))
            replies.append(decoded)


q : [go see them]; a : [i was thinking of that]
q : [a unk of the before we say goodnight from last at unk state park in maine]; a : [this is a great idea to be a great day for a while]
q : [unless you want this ]; a : [what is he]
q : [my fav moment from the debate last night]; a : [wait for the first time]
q : [ok i dont see any catholic terrorist]; a : [not even to be a threat to the point]
q : [thats your sister]; a : [i dont know what i was talking about]
q : [radical islam unk a threat to the united states and our leaders need to realize this before its too late]; a : [is that a joke]
q : [literally the same thing happened to me ]; a : [thats what i said]
q : [last chance to win vip passes to new york comic con amp meet the walking dead cast go]; a : [if you were in the same place i dont have to see it]
q : [4 correction that video is from a few years ago]; a : [its been a fan of my life but i dont know what to do]
q : [we are doing band there are many unk in the band]; a : [i have to be a good job]
q : [im sure it does but i doubt ill see a unk amount of money from it]; a : [i think its a good idea]
q : [which report did this graph come from the unk unk data is really interesting and hard to find]; a : [is this a lot of times from the world of the world of the year]
q : [thats pretty cool but now i am dying to find out what s first tweet will be]; a : [it was a good time for the first time]
q : [great debate poll numbers  i will be on at 700 to discuss enjoy]; a : [dont have to be a president]
q : [yooo me too]; a : [ahh i know i was just thinking about this]
q : [the ladies of could not be more idiotic or blind they should invite on for a talk]; a : [they are not sarcastic]
q : [clothes that dont fit me no more]; a : [ur so cute]
q : [good evening unk]; a : [good morning all]
q : [so pretty much she didnt want him so u were is 2nd choice ]; a : [lol i dont know what to say about it ]
q : [another reminder of my favorite quote people sell what they need and buy what they dont need thanks]; a : [this is a joke]
q : [the point is there is unk to a hate and fear unk campaign]; a : [you dont care about the debate that is not a fact that you are not a racist]
q : [which one is he]; a : [hes a good one]
q : [our diversity is our strength is the most dangerous statement do not be fooled diversity destroys nations]; a : [is this a new yorker of the world terrorism]
q : [i just want to set up a casual fuck buddy situation that slowly but surely unk into a wedding marriage]; a : [have to be a good day and ill be able to be able to help]
q : [me amp bae tryna get back to us ]; a : [cant wait to see you]
q : [probably not]; a : [you dont know what to do with you]
q : [fuck that shit lol]; a : [lol i know that was a joke]
q : [jumping the shark]; a : [so much the way to the game]
q : [my fave when you wake up]; a : [omg this is so cute]
q : [lol all of you guys are idiots over 2 million people live here teams in smaller markets still support]; a : [not have to be a good place]
q : [as long as nobody who ever had a mother votes for him we should be ok]; a : [what about the media is not in the us terrorism and not not the right]
q : [nice running into you]; a : [not a good time]
q : [its taking over lol]; a : [lol i dont even know what to say]
q : [part 4 on exclusive investigation into  unk minister in the unk]; a : [why is this a joke]
q : [heres the unk its unk]; a : [i think the same thing is there]
q : [hillary clinton needs to be arrested she has committed more crimes than the majority of those in our unk]; a : [are you going to be a liar for a landslide]
q : [who you talking abt sis]; a : [dont be a bitch]
q : [get your facts straight youre the one that should feel guilty]; a : [its not a joke but its a threat to the point of the planet]
q : [i received my passport  im ready to vote for my country for you for my daughter for women workers]; a : [good luck ]
q : [you need to unk that woman with her past expose for all of the crimes she committed against humanity]; a : [i dont think she was born in the middle of the middle of the middle of the debate]
q : [what conservatives dont understand is i would have done the same for ]; a : [you are a fan of the same ones]
q : [should i go medium or large if skinny but weirdly long arms or is there a size chart somewhere]; a : [maybe its been a fan of the game]
q : [its okay sometimes i like to go back and delete a bunch of tweets that didnt get any favs]; a : [lmao i dont know what i feel about it i dont even know how to do]
q : [whats really scary is that about a quarter of the unk actually think unk is sincere]; a : [not sure if it was a lot of people]
q : [unk bring this back to the club ffs]; a : [did you know that cares about]
q : [yep this is where ill be sunday because ]; a : [if you can find the same version of the game]
q : [its not even your birthday stop trying to make it happen early]; a : [its not a good one]
q : [ive now got the next unk]; a : [damn i was there]
q : [i believe you were asking about something like this a while back]; a : [it was a joke but i dont think it was a lot of people]
q : [so what its just the internet on a smaller screen]; a : [is it on the way]
q : [im not white ]; a : [what are you talking about]
q : [they want unk from responsibility]; a : [they are not a racist]
q : [how when and where to vote for bernie]; a : [trump is a lying woman to get a wall in the country]
q : [you know how retarded this is]; a : [it was a joke]
q : [when unk kelly asked miss universe this question about donald trump she had no answer]; a : [and you dont know what to say about the debate is a fact]
q : [happy unk day to my brother love you fam ]; a : [love you too much love you too ]
q : [can anyone guess how little i care what a poll says about this subject]; a : [i think the same thing is that is the problem of the truth]
q : [thats what i said it was the live]; a : [it was so good i was in the city]
q : [unk your office]; a : [i think the same thing is that]
q : [they have a travel course for the summer and i really want to go but its a lot of money]; a : [ill be there for a while to get a new one ]
q : [can i get a big big thank you amp rt for our amazing unk today]; a : [love the love thank you ]
q : [after bombing attempts around new york congress wants unk to secure unk buses via]; a : [ you need to get a chance to get a wall in the future]
q : [smh i thought you meant crack cocaine]; a : [you know what the fuck is]
q : [hillarys been failing for 30 years in not getting the job done  it will never change]; a : [you are a moron]
q : [5 unk to increase member engagement by ]; a : [and they are]
q : [wow just woke up in phoenix and going to play with unk tonite]; a : [its a good time to get a pic of me]
q : [its a hell of a lot of fun]; a : [i love it]
q : [the girl in the back looks scary af]; a : [thats the cutest]
q : [where did he go]; a : [just a good one]
q : [wow you deserve a unk check your dms ]; a : [i love this]
q : [i didnt have a very good first impression with her ]; a : [this is a good thing]
q : [moves back to sj in november]; a : [hey i will be there]
q : [why doesnt or anyone from get additional info]; a : [because i dont even know if you want to be a good one of the year]
q : [damn im loving this track and so unk good lt3 lt3]; a : [happy birthday ]
q : [that would be a terrible unk in their security]; a : [maybe he was]
q : [have you seen the magnificent 7 yet]; a : [not heard it was a good idea]
q : [dang it mike thats how the brexit happened]; a : [its a good thing to be a guy]
q : [live on  new bone ]; a : [this is so good]
q : [hes from the old country its understandable]; a : [just even on the debate]
q : [someone please give me better unk dramatic music to listen to]; a : [dont even know that it was a good thing]
q : [got me as a wack unk im not following that shit]; a : [you dont know what you mean]
q : [unk in new york are so fucking unk and extra]; a : [i know i know]
q : [whats up man actually sold unk in july im working in the city now]; a : [what about the world]
q : [when it comes to story easiest way to fix something is to cut it kind of like civil war surgery]; a : [they dont even be a fan of the game of the first time]
q : [its in 8 months]; a : [its a good time to get a new phone]
q : [lets unk the gender unk in tech]; a : [i need to get a new one]
q : [haha someones enjoying sf a bit too much ]; a : [you know i was going to be a good day ]
q : [real nigga hours coming soon]; a : [you got me cry ]
q : [who the fuck are the anti unk league]; a : [heres a new yorker]
q : [my cat is very comfortable me not so much]; a : [not like a lot of the time of the middle]
q : [its very upsetting that i have to miss my first womens world championship for many reasons]; a : [did you have a good time to get a new phone]
q : [i think it was pre filmed]; a : [ i dont know what to do]
q : [guys i met this weekend and he told me the meaning of life]; a : [the best thing ever]
q : [i dont bang people outside the industry]; a : [dont have to be a fan of the time]
q : [hes a major league baseball player with three fucking rings not a 5 year old fucking idiot]; a : [probably even to be a fan of a joke]
q : [rub my ass]; a : [are you coming to the gym]
q : [im going to lady problems unk  new york see you there via]; a : [did you have any other ideas to get the link to the next one]
q : [oh hey insights from on amp at unk on cant wait]; a : [let me know if you get a new phone]
q : [happy birthday unk you are beautiful inside and out i miss and love you very much ]; a : [thank you so much love you too ]
q : [because he doesnt want to offend the actual enemy]; a : [no he has no idea what he wants]
q : [go unk they said good for your health they said tell that to my broken unk ]; a : [i dont even know what i was thinking about it but i dont even know how to do it]
q : [my heart gets so happy every time i think about unk starting this weekend]; a : [omg i was so happy to see that]
q : [who has a drone they wanna bring to meet n cheat new york lol]; a : [ill be in the city room now]
q : [so far im not too impressed with netflix original tv shows good thing i dont have to pay for it]; a : [i think they have a chance to get a better game of the game]
q : [got my copy cant wait to pop my cherry cherry]; a : [did you get a new one of the world of the day ]
q : [unk youre the one for me lets date cutie]; a : [hey i love you]
q : [who is the keith in this video doesnt look anything like scott]; a : [this is my favorite tweet ever]
q : [first time a celebrity came on and he wasnt the unk]; a : [lmfao im just thinking about that i was just thinking about it]
q : [happy happy birthday unk ]; a : [thank you ]
q : [my mom has 8 cats eight cats]; a : [damn shit is that a thing]
q : [so is new music up to par with the new look and new attitude]; a : [this is so cute i love it]
q : [i miss you so much it hurts]; a : [miss you too ]
q : [thanks v much for invitation]; a : [thanks for the retweet i hope you had a great time to see you]
q : [who do you think won last nights ]; a : [who cares about]
q : [one of unk two is false and the other is unk the false i think the opposite of you]; a : [i think they were a fan of the world]
q : [well know weve made it in life when our apartment has air conditioning]; a : [it was so good]
q : [hey atleast he can talk to his audience clinton has some serious unk issues with unk and lying]; a : [and he said it before he was a good job]
q : [unk heres that sharing word again i dunno chelsea clinton]; a : [if you have a chance of the debate of the debate]
q : [cool im at work eating lunch ]; a : [you can i get a new phone ]
q : [3000 miles away and he still unk to get me breakfast in bed on my bday ]; a : [lol i was just thinking about this  i just got to go to my face ]
q : [which one]; a : [the only one]
q : [join us its an elite group]; a : [its a good thing]
q : [unk morning joe put her on instead]; a : [you know what you mean]
q : [my unk new thing is sending out a unk good morning text every fucking morning ]; a : [you got a good one]
q : [want a gf but i enjoy not having someone else to spend money on]; a : [you can me be a good one]
q : [whos an app developer i low key believe i have a great app idea and high key want to start]; a : [yes we can certainly help you in developing your dream app]
q : [wtf deadass thats crazy]; a : [lol i know i was going to be a fan of my life]
q : [how do you unk bullying like this]; a : [i was thinking of this]
q : [wait where]; a : [not a joke]
q : [unk the difference unk colin kaepernick has made via]; a : [the only thing is the only thing that matters is that]
q : [missed the unk my life is better for it]; a : [its gonna be a good one]
q : [hang on i have to get unk itll take me a minute to reply]; a : [ill be there for a while]
q : [i think i did on sunday sorry ]; a : [did you have a chance]
q : [this guy isnt very nice]; a : [it was not a good thing]
q : [absolutely eliminate welfare good call on your part]; a : [very very good]
q : [your office view ]; a : [this is so cute]
q : [wait no wtf shes unk money from my checking to my own unk wtf nvm she still used my money]; a : [she needs to be a little girl ]
q : [i didnt make it tho just go to a]; a : [dont you have to be a good one]
q : [didnt you unfollow me jessica]; a : [no i dont know what to do]
q : [please unfollow if you are unk to retweet this unk]; a : [no one is so good]
q : [lol yea i bet everyone who works there is  but im depressed i shouldve asked for her unk]; a : [ill be a good time to be a little bit ]
q : [i do this all the time]; a : [you should be a little fan of you]
q : [he might be the best actor ever but what the heck is all this mess about]; a : [the only one of the best things]
q : [me unk through the rest of the week]; a : [love this pic ]
q : [god im so sick of people thinking that theyre artists for putting some j unk beat over a jazz sample]; a : [oh ok i have to be a fan of the game]
q : [either or i work my ass off to support my family and pay my taxes no food unk]; a : [its not a joke but its a good thing]
q : [hard life today]; a : [i know its a good one of the day]
q : [lauren is awful because of her shady af reaction gifs lmao]; a : [thats like he has a lot of money]
q : [then theres me like]; a : [ you have to be a little fan ]
q : [well now theyre saying that i not only won the nbc presidential forum but last night the big debate nice]; a : [are you gonna be a fan of the first time ]
q : [your vote  your chance to have a voice in this election register today  ]; a : [you know what the hell is]
q : [you gave uncle rudy unk deserved props i appreciate your honesty]; a : [you are a lot of people who are a little different man]
q : [we ordered them so they should be coming soon]; a : [i am so excited to hear this]
q : [where is bob]; a : [new york and 6th]
q : [whenever i scroll thru facebook and see this ad i think its for a second]; a : [it was a joke but i dont even know what to do]
q : [lol unk jackson u sold ya soul b]; a : [you dont know what you want]
q : [she supports my congressman]; a : [she is so cute]
q : [of course lol u dont know unk unk]; a : [dont know what to do]
q : [you know nothing about your husband does she or doesnt she]; a : [she doesnt care about that]
q : [sending you all the healing thoughts ]; a : [i am so excited for this]
q : [see this recipe for russian unk ball soup calls for several garlic unk]; a : [ he is a big guy]
q : [isnt that just unk tag and unk]; a : [good to know]
q : [i found it challenging when i wanted to edit directions]; a : [i dont know that it was a good idea but i have a lot of people]
q : [this sequel to what is code is no quick afternoon read]; a : [still a good idea]
q : [yall both lowkey rich tho lol]; a : [you dont know what they say]
q : [fill stop this is mine and unk thing]; a : [looks like it was a good thing]
q : [how about people who take advantage of porn stars]; a : [yeah i think its not a good idea but its not a good thing]
q : [when you hear a unk ring in your apt and you dont have a unk]; a : [who is that]
q : [as a state worker id have no problem paying for my insurance and unk]; a : [if you have a chance to be in the city]
q : [lt i was talking to her lol bigots i didnt think my spelling would be the part to offend u]; a : [she was so cute and she was so mad ]
q : [knowing nothing about this at all this looks awesome]; a : [it was a great thing to be a good guy]
q : [the sweet irony of trumps biggest campaign problems]; a : [dont think the same thing is that]
q : [im overwhelmed couldnt imagine the hospitals doctors they must be on stress leave]; a : [wait i was just thinking about this]
q : [your mom drives it everywhere ]; a : [she is so cute ]
q : [this tweet makes me sad]; a : [i dont think so but i dont think so]
q : [exclusive video donald trump claims his microphone was defective says its a conspiracy against him]; a : [i think he was born in the middle of the debate]
q : [i was against going into iraq trump unk in florida not any unk today than it was yesterday]; a : [is that a joke that is a joke to the trump foundation and trump is not a racist]
q : [i have studio in an hour and im hella unk oh god]; a : [its a good thing to get a pic of the time]
q : [oct 6 until whenever shows up becomes a robot and cant thumbs]; a : [i can relate to the gym and i can get it]
q : [with right around the corner i thought this very fitting safe travels everyone ]; a : [omg i love this pic  i love you]
q : [probably not a good idea to call people crooked unk when you look like a twisted troll]; a : [if you can say that i can get a pic of my life and a half months ago]
q : [startups can take unk risk with indian money unk via]; a : [this is a great place to see]
q : [celebrity styles unk unk]; a : [he was so cute]
q : [and it never happened before ice age never happened nor unk just now give me a break]; a : [the whole thing is that the first thing i was]
q : [lmao jus tryna enjoy the day off]; a : [lol i got to get a ticket ]
q : [i prefer your unk feed]; a : [no no one is a joke]
q : [also what kind of question is that]; a : [not sure the same thing]
q : [the bikes are way better than the cars i think]; a : [are you all of the us]
q : [rt to win black rose gold unk brush set  must be following me so i can dm winner]; a : [i know right but i was just thinking about it]
q : [playing holy spirit by unk]; a : [beautiful pic ]
q : [ can pm share such messages over letter head]; a : [ and do you have to be a good job]
q : [if you get this super unk joke lets be friends]; a : [ill be there for a few days ago]
q : [it was so damn weird but i laughed my ass off hah]; a : [was a joke lol]
q : [tell me more what does it do]; a : [just like the same thing to the end of the game]
q : [uh  i read something about this 2 days ago ill try to find the link]; a : [it was so good to me]
q : [who will i be seeing at the this winter vip on sale today ga on sale this]; a : [you can be there in the city but i will be there]
q : [many people are saying that s are the result of a cocaine problem many many people credible sources]; a : [what is the point of the truth]
q : [i crashed it damnit lin when will you learn]; a : [if you dont have any other choice to do with you]
q : [i am so proud and unk]; a : [you know that]
q : [oh man this shit got me real emotional rip unk]; a : [you know what to say]
q : [eric trump unk dads courage in not bringing up bill clintons unk]; a : [he is a lot of people who have a good job to get a man]
q : [im watching with my daughter]; a : [youre so cute]
q : [that is impressive how long did they take to prepare]; a : [looks like a lot of the game]
q : [i think something else was defective  what he said or rather unk]; a : [i dont know what to say about it]
q : [roasted unk amp black unk 9]; a : [you should be so happy to see that]
q : [shes really asking the hard hitting question chris]; a : [i think he was a lot of people who would have a better chance of the debate]
q : [i was raised to always do that but honestly i think im done]; a : [that was so good]
q : [think she slick aint no unk from this ass unk you got coming ]; a : [she told me to get a pic]
q : [student 6 in critical condition after school shooting]; a : [maybe we need to get a better job for the debate]
q : [you need promotion your music on soundcloud only unk promotion here more info in my twitter here prices unk]; a : [hey is the best thing ive seen it]
q : [ash watch juan hes like actually unk and smiling too sweet]; a : [i know right]
q : [thats good  it was 2013 i think]; a : [and i was in the same place ]
q : [ive came to the unk that sex really aint shit if you dont love the person]; a : [youre a joke]
q : [when you want to laugh at americans for letting trump happen and then you remember unk and unk]; a : [who cares about this]
q : [still make the same face]; a : [i dont even know what to do]
q : [i think they played in on unk theater a few years back too]; a : [no i dont even know how to do it]
q : [do it jess its protein that makes it okay]; a : [its not even a thing]
q : [have a question for  submit it below and she may answer it in the ]; a : [i dont think the same thing is the only one who would]
q : [such a great honor final debate polls are in  and the movement wins ]; a : [ we need to get rid of the debate]
q : [some very promising unk 2 numbers for  dropping only 02 from premiere to a 26 very decent hold]; a : [is it a great thing to be in the city]
q : [lol im about to fire yall]; a : [im going to be a while fan ]
q : [how can i come see you play tomorrow ]; a : [come to sf ]
q : [take me back before the jump though unk]; a : [dont know what you mean about that shit lmao]
q : [exactly also i would consider it a party and invite people over to watch unk unk actually play]; a : [its not a thing]
q : [so glad you enjoyed it yes unk co unk dm me]; a : [glad i was there]
q : [so i had to look it up unk and wig sold unk thats that bullshit right there]; a : [what is this]
q : [in public space not on private unk these protesters are unk]; a : [i agree but the media is not a terrible choice]
q : [wassup i got some rare shit unk have to bring the price up to 25 tho]; a : [i wish i could be there]
q : [love watching unk too but almost feels painful to watch him pitch such unk]; a : [it was a good thing to be a good game]
q : [ive never unk my sleep before but i think this is pretty alright]; a : [that is the most thing ive seen it]
q : [unk and yourself have roughly the same level of credibility]; a : [what the fuck]
q : [this should help him with women]; a : [did he get a good time to get a pic of him]
q : [what the heck i just sent you a video link]; a : [i feel you so much i was gonna get a pic of my phone]
q : [why you so perfect]; a : [i know i am so happy for you ]
q : [unk someone block you again cause ur not supporting unk x xd]; a : [dont know what you mean ]
q : [when you say black i take it you mean unk]; a : [who said that]
q : [did you get tickets already]; a : [ i got to go to the airport]
q : [you are such a unk all bullshit with no facts get over your stupid unk]; a : [you are a racist person who are you talking about your own business]
q : [not sure what you meant by that]; a : [ i know right]

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: