Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nasavish committed Oct 26, 2018
2 parents deecfbb + 18fad8e commit d5e1f3e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Binary file not shown.
14 changes: 10 additions & 4 deletions word_based.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
" text = f.read()\n",
" modelList = text.split(']')[0] + ']'\n",
" modelHistory = '{' + ']'.join(text.split(']')[1:]).split('{')[1]\n",
" print(f\"NEW DATA: {date+'_'+time}\")\n",
" #print(f\"NEW DATA: {date+'_'+time}\")\n",
" modelHistory = ast.literal_eval(modelHistory)\n",
" modelList = ast.literal_eval(modelList)\n",
" epochs = modelHistory['epochs']\n",
Expand All @@ -489,8 +489,13 @@
" datetime[date+'_'+time] = {'model_list': modelList,\n",
" 'model_history': modelHistory,\n",
" 'sequence_list': ['no_model_data']*(epochs+1)}\n",
" print(datetime)\n",
" datetime[date+'_'+time]['sequence_list'][int(epoch)] = generate_seq(os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)\n",
" try:\n",
" seq_length = modelHistory['seq_length']\n",
" except:\n",
" seq_length = 50\n",
" #print(f'{epoch}: {datetime}')\n",
" #seq_length, seed_text, n_words, filepath = '', modelName = '', tokenizerName = '', )\n",
" datetime[date+'_'+time]['sequence_list'][int(epoch)] = generate_seq(seq_length, seed.seed_text, 50, filepath, filename, tokenizer) \n",
" print('\\n',filename, \": \",datetime[date+'_'+time]['sequence_list'][int(epoch)])\n",
" #-- Write JSON file -- --- ----\n",
" with open(jsonFile, 'w+') as fp:\n",
Expand Down Expand Up @@ -519,7 +524,8 @@
" epoch, loss, modellist = m.group(1), m.group(2), m.group(3)\n",
" jsondict['model'] = modellist\n",
" jsondict['loss'][int(epoch)] = float(loss)\n",
" jsondict['sequences'][int(epoch)] = generate_seq(os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)\n",
" #seq_length, seed_text, n_words, filepath = '', modelName = '', tokenizerName = '', )\n",
" jsondict['sequences'][int(epoch)] = generate_seq(50, seed.seed_text, 50, os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)\n",
" print(epoch, ': ', jsondict['sequences'][int(epoch)])\n",
" #-- Write JSON file -- --- ----\n",
" with open(jsonFile, 'w+') as fp:\n",
Expand Down
14 changes: 10 additions & 4 deletions word_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def json_create(filepath = '.'):
text = f.read()
modelList = text.split(']')[0] + ']'
modelHistory = '{' + ']'.join(text.split(']')[1:]).split('{')[1]
print(f"NEW DATA: {date+'_'+time}")
#print(f"NEW DATA: {date+'_'+time}")
modelHistory = ast.literal_eval(modelHistory)
modelList = ast.literal_eval(modelList)
epochs = modelHistory['epochs']
Expand All @@ -362,8 +362,13 @@ def json_create(filepath = '.'):
datetime[date+'_'+time] = {'model_list': modelList,
'model_history': modelHistory,
'sequence_list': ['no_model_data']*(epochs+1)}
print(datetime)
datetime[date+'_'+time]['sequence_list'][int(epoch)] = generate_seq(os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)
try:
seq_length = modelHistory['seq_length']
except:
seq_length = 50
#print(f'{epoch}: {datetime}')
#seq_length, seed_text, n_words, filepath = '', modelName = '', tokenizerName = '', )
datetime[date+'_'+time]['sequence_list'][int(epoch)] = generate_seq(seq_length, seed.seed_text, 50, filepath, filename, tokenizer)
print('\n',filename, ": ",datetime[date+'_'+time]['sequence_list'][int(epoch)])
#-- Write JSON file -- --- ----
with open(jsonFile, 'w+') as fp:
Expand All @@ -389,7 +394,8 @@ def jsonify_the_old_style_file(filepath = '.'):
epoch, loss, modellist = m.group(1), m.group(2), m.group(3)
jsondict['model'] = modellist
jsondict['loss'][int(epoch)] = float(loss)
jsondict['sequences'][int(epoch)] = generate_seq(os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)
#seq_length, seed_text, n_words, filepath = '', modelName = '', tokenizerName = '', )
jsondict['sequences'][int(epoch)] = generate_seq(50, seed.seed_text, 50, os.path.join(filepath,filename), tokenizer, 50, seed.seed_text, 50)
print(epoch, ': ', jsondict['sequences'][int(epoch)])
#-- Write JSON file -- --- ----
with open(jsonFile, 'w+') as fp:
Expand Down

0 comments on commit d5e1f3e

Please sign in to comment.