Skip to content

Commit

Permalink
hi
Browse files Browse the repository at this point in the history
  • Loading branch information
jshtaway committed Oct 23, 2018
1 parent 3b59b19 commit 6cf8a7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions word_based.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
" drseuss_text = 'data/combinedText.txt'\n",
" seed_length = 50\n",
" length = seed_length + 1\n",
" epochs = 3\n",
" epochs = 2\n",
" batch_size = 128\n",
" #-- ---- ---- --- ---- ----- ---- ----- ---- ----- ----- ---- ---- ---- ----\n",
" \n",
Expand Down Expand Up @@ -235,8 +235,8 @@
" modelList = [{'model':'Embedding', 'input_dim':vocab_size, 'output_dim': 512, 'input_length': seq_length},\n",
" {'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True}, \n",
" {'model': 'Dense','units':100,'activation':'relu'}, \n",
" {'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True}, \n",
" {'model': 'Dense','units':100,'activation':'relu'}, \n",
"# {'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True}, \n",
"# {'model': 'Dense','units':100,'activation':'relu'}, \n",
" {'model':'Flatten'},\n",
" {'model': 'Dense','units':vocab_size,'activation':'softmax'},\n",
" ]\n",
Expand All @@ -255,8 +255,8 @@
" #-- Fit model -- ---- --- --- --- ---- --- --- ---- --- --- --- --- --- --- --- --- \n",
" history_callback = modelFit(model, modelName, X, y, seq_length, batch_size, epochs, results_path)\n",
" loss_history = history_callback.history\n",
" with open(results_path.rstrip('/').lstrip('/') + f'/{modelName}_loss_history.txt') as f:\n",
" f.write(loss_history)"
" with open(results_path.rstrip('/').lstrip('/') + f'/{modelName}_loss_history.txt', 'w+') as f:\n",
" f.write(str(loss_history))"
]
},
{
Expand Down Expand Up @@ -457,7 +457,7 @@
" #print(f\"{date+'_'+time} not in KEYS: \\n{datetime.keys()}\")\n",
" tokenizer = filepath+f'/token_{date}_{time}.pkl'\n",
" try:\n",
" with open(filepath+'/info_' + date+'_'+time + '.txt') as f:\n",
" with open(filepath.rstrip('/').lstrip('/')+'/info_' + date+'_'+time + '.txt') as f:\n",
" text = f.read()\n",
" modelList = text.split(']')[0] + ']'\n",
" modelHistory = '{' + ']'.join(text.split(']')[1:]).split('{')[1]\n",
Expand All @@ -466,7 +466,7 @@
" modelList = ast.literal_eval(modelList)\n",
" epochs = modelHistory['epochs']\n",
" if os.path.isfile(f\"{date+'_'+time}_loss_history.txt\"):\n",
" with open(f\"{date+'_'+time}_loss_history.txt\") as f:\n",
" with open(f\"{filepath.rstrip('/').lstrip('/')}/{date+'_'+time}_loss_history.txt\") as f:\n",
" model_history = f.read()\n",
" model_history = ast.literal_eval(model_history)\n",
" modelHistory['model_history'] = model_history\n",
Expand Down
14 changes: 7 additions & 7 deletions word_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def trainModelComplete(results_path):
drseuss_text = 'data/combinedText.txt'
seed_length = 50
length = seed_length + 1
epochs = 3
epochs = 2
batch_size = 128
#-- ---- ---- --- ---- ----- ---- ----- ---- ----- ----- ---- ---- ---- ----

Expand Down Expand Up @@ -215,8 +215,8 @@ def trainModelComplete(results_path):
modelList = [{'model':'Embedding', 'input_dim':vocab_size, 'output_dim': 512, 'input_length': seq_length},
{'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True},
{'model': 'Dense','units':100,'activation':'relu'},
{'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True},
{'model': 'Dense','units':100,'activation':'relu'},
# {'model': 'LSTM', 'units':512, 'use_bias':True, 'dropout':.2, 'recurrent_dropout': 0, 'return_sequences': True},
# {'model': 'Dense','units':100,'activation':'relu'},
{'model':'Flatten'},
{'model': 'Dense','units':vocab_size,'activation':'softmax'},
]
Expand All @@ -235,8 +235,8 @@ def trainModelComplete(results_path):
#-- Fit model -- ---- --- --- --- ---- --- --- ---- --- --- --- --- --- --- --- ---
history_callback = modelFit(model, modelName, X, y, seq_length, batch_size, epochs, results_path)
loss_history = history_callback.history
with open(results_path.rstrip('/').lstrip('/') + f'/{modelName}_loss_history.txt') as f:
f.write(loss_history)
with open(results_path.rstrip('/').lstrip('/') + f'/{modelName}_loss_history.txt', 'w+') as f:
f.write(str(loss_history))


# In[8]:
Expand Down Expand Up @@ -330,7 +330,7 @@ def json_create(filepath = '.'):
#print(f"{date+'_'+time} not in KEYS: \n{datetime.keys()}")
tokenizer = filepath+f'/token_{date}_{time}.pkl'
try:
with open(filepath+'/info_' + date+'_'+time + '.txt') as f:
with open(filepath.rstrip('/').lstrip('/')+'/info_' + date+'_'+time + '.txt') as f:
text = f.read()
modelList = text.split(']')[0] + ']'
modelHistory = '{' + ']'.join(text.split(']')[1:]).split('{')[1]
Expand All @@ -339,7 +339,7 @@ def json_create(filepath = '.'):
modelList = ast.literal_eval(modelList)
epochs = modelHistory['epochs']
if os.path.isfile(f"{date+'_'+time}_loss_history.txt"):
with open(f"{date+'_'+time}_loss_history.txt") as f:
with open(f"{filepath.rstrip('/').lstrip('/')}/{date+'_'+time}_loss_history.txt") as f:
model_history = f.read()
model_history = ast.literal_eval(model_history)
modelHistory['model_history'] = model_history
Expand Down

0 comments on commit 6cf8a7b

Please sign in to comment.