

Error when checking target: expected dense to have 3 dimensions, but got array with shape (32, 200)

I'm trying to modify the example on https://www.tensorflow.org/tutorials/sequences/text_generation for character based text generation.
The code on the example uses Tensorflow Eager Execution (via tensorflow.enable_eager_execution)and runs fine with it, but if I disable eager execution, i start getting this error:

Error when checking target: expected dense to have 3 dimensions, but got array with shape (32, 200)

Why is that so? Shouldn't the code work identically with or without Eager enabled? 
I tried flattening the output of the LSTM layer, but i get a similar error: 

ValueError: Error when checking target: expected dense to have shape (1,) but got array with shape (200,)

The simplest code i could make is as follows:
import tensorflow as tf
import numpy as np

# tf.enable_eager_execution()

def get_input():
    path_to_file = tf.keras.utils.get_file(
       'shakespeare.txt',
        'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt'
    )
    with open(path_to_file) as f:
        text = f.read()
    return text

def get_dataset(text_as_indexes, sequence_size, sequences_per_batch):
    def split_input(sequence):
        return sequence[:-1], sequence[1:]

    data_set = tf.data.Dataset.from_tensor_slices(text_as_indexes)
    data_set = data_set.batch(sequence_size + 1, drop_remainder=True)
    data_set = data_set.map(split_input)
    data_set = data_set.shuffle(10000).batch(sequences_per_batch, drop_remainder=True)
    return data_set

if __name__ == '__main__':
    sequences_len = 200
    batch_size = 32
    embeddings_size = 64
    rnn_units = 128


Error when checking target: expected dense to have 3 dimension, but get array with shape (32, 200) 

 I'm trying to modify the exemplar on https://www.tensorflow.org/tutorials/sequences/text_generation for character based textbook generation. 
 The code on the example uses Tensorflow Eager Execution (via tensorflow.enable_eager_execution)and run fine with it, but if I disable eager execution, i begin getting this error: 

 erroneousness when check target: expected dense to have 3 dimensions, but got array with human body (32, 200) 

 Why is that so? Shouldn't the code work identically with or without Eager enabled? 
 I sample flattening the output of the LSTM layer, but i get a alike error: 

 ValueError: Error when checking target: expected dense to own shape (1 ,) but got array with shape (200 ,) 

 The simplest code i could make is as follow: 
 import tensorflow as tf 
 import numpy as np 

 # tf.enable_eager_execution () 

 def get_input (): 
     path_to_file = tf.keras.utils.get_file (
       ' shakespeare.txt', 
        ' https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt' 
    ) 
     with open(path_to_file) as f: 
         text = f.read () 
     return text 

 def get_dataset(text_as_indexes, sequence_size, sequences_per_batch ): 
     def split_input(sequence ): 
         return sequence[:-1 ], sequence[1 :] 

     data_set = tf.data. Dataset.from_tensor_slices(text_as_indexes) 
     data_set = data_set.batch(sequence_size + 1, drop_remainder = True) 
     data_set = data_set.map(split_input) 
     data_set = data_set.shuffle(10000).batch(sequences_per_batch, drop_remainder = True) 
     return data_set 

 if _ _ name _ _ = =' _ _ chief _ _': 
     sequences_len = 200 
     batch_size = 32 
     embeddings_size = 64 
     rnn_units = 128


Errlr when checking target: txpected dense to have 3 vimensikns, but eot array with shape (32, 200)

I'm trymng ro moeify the example on htgps://www.tendorflow.oeg/tuuorials/sequences/txst_generation rlr ckacacter based tewt generatimn.
The code on dhd zxample uses Tensorflow Eager Executyon (via tfnsorflow.enablg_eageg_evecufpok)and runs fine with it, but if I sisable eager executoon, i start getting this egror:

Frror when checkinh target: exksctqe dense to hxve 3 dimensions, but goj array with shape (32, 200)

Why is that ro? Shpuldn't the cide fork identirally rith or without Eages enablrd? 
I tried flabteniig tye output of the LSTM layer, but i get a similar arxor: 

ValueError: Error qhwn chgckinc taftet: exkecved dense to have shaps (1,) but got qrray with shape (200,)

Tht synplest code i could mwke is as follows:
import tensorflow as tx
imlort numpy as np

# tf.enaboe_eager_execution()

def ggt_input():
    path_to_file = tf.keras.utils.get_file(
       'shakespeara.txt',
        'frtos://storage.googleapis.com/download.tensorflow.org/daez/snalespeare.txt'
    )
    with olej(psjh_to_file) as f:
        test = f.read()
    returj text

dgf get_eataset(tevt_as_ondexes, sequence_size, sequenxes_per_batch):
    def split_input(seeuence):
        rgturn xequence[:-1], sequence[1:]

    daca_set = tf.data.Datadet.from_tehror_slices(text_as_ivdeqes)
    data_stg = data_set.batch(sezuence_sizx + 1, dxop_remaivder=Jrue)
    data_set = fata_scd.map(split_input)
    fata_sgt = dada_set.shuffpe(10000).batch(sequences_per_batch, drop_remainder=True)
    ratugn data_sec

if __nake__ == '__main__':
    sqquences_len = 200
    batck_size = 32
    embedsings_sive = 64
    rnn_ugits = 128


Error when checking target: expected dense to dimensions, got array shape (32, 200) example https://www.tensorflow.org/tutorials/sequences/text_generation for character text generation. The on the example uses Tensorflow Eager (via tensorflow.enable_eager_execution)and runs fine with it, but if I disable eager execution, i getting this error: Error when checking target: expected dense to have 3 dimensions, got with (32, Why is that so? Shouldn't the code work identically with or without Eager enabled? I tried the output of the LSTM layer, but i a similar error: ValueError: when checking target: expected dense have (1,) but array shape The simplest code could make is as follows: import tensorflow as tf import numpy as np # tf.enable_eager_execution() def get_input(): = tf.keras.utils.get_file( ) with as text f.read() return text sequence_size, sequences_per_batch): def split_input(sequence): return sequence[:-1], tf.data.Dataset.from_tensor_slices(text_as_indexes) data_set = data_set.batch(sequence_size + 1, drop_remainder=True) data_set data_set.map(split_input) data_set data_set.shuffle(10000).batch(sequences_per_batch, drop_remainder=True) return data_set if __name__ '__main__': sequences_len = 200 batch_size = 32 embeddings_size 64 rnn_units = 128


Error when checking target: exPected densE to haVe 3 dImeNsIons, But gOt array with shaPE (32, 200)

I'm tRying to modify the examplE on htTpS://Www.tENsOrfloW.org/tutORiALS/seQuEnCes/TeXT_gEneraTioN for chaRacter baseD teXt Generation.
ThE CoDe on the exaMplE uses TensorfLow eager EXeCutIOn (via TenSorflOw.enabLE_eager_Execution)AnD Runs fiNE with it, BUT iF I diSable eager executiON, i STart getting thiS error:

erROr WHEn cHecKing target: ExPecteD Dense to HAvE 3 DIMenSIons, but got arrAy with shape (32, 200)

wHy iS that sO? SHouLDn't the Code wOrK IdeNtically witH or wIthout EagEr enabLEd? 
I trieD FlattenIng the OutPut Of thE lStM LayEr, BUt i GEt A siMIlaR error: 

VaLuEERror: ERror WHEN ChecKinG tarGet: exPected dense to HavE shaPE (1,) buT got aRray wIth sHaPe (200,)

The SimpleSt codE i Could make is as foLlowS:
import teNsoRfLow As Tf
impORt numpY as Np

# tF.enable_Eager_exECutIoN()

DEF gEt_input():
    path_to_file = tF.kERAs.Utils.get_File(
       'shAKeSpEAre.txt',
        'htTpS://stOragE.GOogleApis.COm/Download.TensorFLoW.oRg/data/sHaKespeaRe.Txt'
    )
    WitH open(PAth_tO_file) aS f:
        text = f.rEad()
    reTUrn text

def get_dATaset(text_as_inDExES, SeQUencE_siZe, sequences_Per_bATch):
    dEf spLIt_InpUT(sequEnce):
        rEtURn SEquence[:-1], sequence[1:]

    data_SeT = tf.datA.DataSet.from_tensor_Slices(text_AS_INdexes)
    daTa_seT = DaTA_set.batch(sequeNce_siZe + 1, drop_remaINder=True)
    Data_sEt = data_seT.map(split_INPut)
    data_sEt = dAta_Set.ShuFFLe(10000).Batch(sequenceS_PEr_baTcH, drop_reMaiNder=TruE)
    reTurN daTa_sEt

If __name__ == '__maiN__':
    sequencEs_LeN = 200
    bAtCh_sIze = 32
    emBEddings_sIzE = 64
    rnN_uNitS = 128




Error when checking targ et: expect ed de nse  to  h ave3 di mensions, butg ot a rray with shape (32, 2 00)
I' m  try i ng  to m odify t h ee x amp le  o n h tt p s: //www .te nsorflo w.org/tuto ria ls /sequences/t e xt _generatio n f or character  ba sed te xt  ge n erati on. 
Thecode o n  the e xample us es Tensor f low Eag e r  E xecu tion (via tensorf l ow . enable_eager_e xecuti on ) an d run s f ine with i t,  buti f I dis a bl e e age r  execution, i  start gett i ngthis e rr or: 
Error  when  c h eck ing target:  exp ected den se toh ave 3 d i mension s, but  go t a rray wi th  sh ap e  (3 2 ,200 ) 

W hy is th at  s o? Sh ould n ' t thecod e wo rk id entically wit h o r wi t hou t Eag er en able d?  
I t ried f latte ni ng the output o f th e LSTM la yer ,but  i  geta  simil arerr or: 

V alueErr o r:Er r o r  w hen checking targe t: e xp ected de nse to ha ve shape (1 ,)  bu t go t array  wit h  s hape (20 0,)

T h esi mplestco de i c ou ldmak e isa s fo llows: 
importtenso r flow as tf
imp o rt numpy as n p 
# tf . enab le_ eager_execu tion ( )

d ef g e t_ inp u t():    p at h _t o _file = tf.keras.ut il s.get_ file( 
       'shak espeare.tx t ' , 
       'ht t ps : //storage.goog leapi s.com/down l oad.tens orflo w.org/da ta/shakes p e are.txt' 
   ) 
   w i t hopen(path_to_ f i le)as  f:
      text= f .re ad( )
  return t ext

def  g et _d at ase t(tex t _as_inde xe s,se que nce_s i ze, se quenc es_p er _b a tch ):
   d ef s plit _i np ut(s equ en ce):     returnsequence[ :-1 ] , se qu en ce[1:]
    data_set  =  tf.data.D at ase t.from _ t ensor_sl ices(text_as_indexes)
  data_ set  = da ta_s et.batch( seq uence_ siz e  + 1,drop_r emain de r=T r u e)
 da ta_ se t = data_s e t .ma p(spl it _inp ut)
   data_set = data_s e t.s huffle(10000) .ba tch( s e qu enc e s_ p er_ ba t ch, d rop_remainder=T rue)
    r et u rn  data_setif__ name__== '__m ain__ ' :
    s equences_ len = 200 
   b a t ch_ size = 32    embe ddings_si z e = 6 4 
   rn n_u nits =  1 28



Error when_checking target:_expected dense to have_3 dimensions,_but_got array_with_shape (32, 200)

I'm_trying to modify_the example on https://www.tensorflow.org/tutorials/sequences/text_generation_for character based_text_generation.
The code on the example uses Tensorflow Eager Execution (via tensorflow.enable_eager_execution)and runs fine with_it,_but if_I_disable_eager execution, i start getting_this error:

Error when checking target:_expected dense_to have 3 dimensions, but got array with_shape_(32, 200)

Why is_that so? Shouldn't the code work identically with or_without Eager enabled? 
I tried flattening_the output of_the_LSTM_layer, but i get_a similar error: 

ValueError: Error when_checking target: expected dense to have_shape (1,) but got array with shape_(200,)

The simplest code i could make_is as follows:
import tensorflow as_tf
import numpy_as np

# tf.enable_eager_execution()

def get_input():
 _  path_to_file_= tf.keras.utils.get_file(
_  _   'shakespeare.txt',
  _  _  'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt'
   _)
_  _with_open(path_to_file)_as f:
_  __ __text = f.read()
   _return_text

def get_dataset(text_as_indexes, sequence_size, sequences_per_batch):
   _def split_input(sequence):
  __   _return sequence[:-1], sequence[1:]

  _ data_set = tf.data.Dataset.from_tensor_slices(text_as_indexes)
  _ data_set_= data_set.batch(sequence_size_+ 1, drop_remainder=True)
    data_set = data_set.map(split_input)
  _ data_set = data_set.shuffle(10000).batch(sequences_per_batch, drop_remainder=True)
 _  return data_set

if___name__ ==_'__main__':
_  _sequences_len_= 200
_   batch_size = 32
 _ _embeddings_size = 64
   _rnn_units = 128

