Network Notes


In [689]:
# good 160 unit *3 network
network_model = "func-28-1-3"
iter1 = 213750
iter2 = 23550
codec = 3200
model_type = 'functional'

output_fn_postfix1 = "output_" + str(0) + "_" + str(iter1)
output_fn_postfix1_mid = "output_" + str(1) + "_" + str(iter1)

output_fn_postfix2 = "output_" + str(0) + "_" + str(iter2)
output_fn_postfix2_mid = "output_" + str(1) + "_" + str(iter2)



from subprocess import check_output, call

import os
import json

home = os.environ.get('HOME')
if codec==3200:
    codec_sub = '-3200'
else:
    codec_sub = ''

os.chdir(home + "/store/c2gen/notebooks")


cb = home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix1)
call(["bash", home + "/store/c2gen/c2towav.sh", cb ])
cb = home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix1_mid)
call(["bash", home + "/store/c2gen/c2towav.sh", cb ])
cb = home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(iter2)
call(["bash", home + "/store/c2gen/c2towav.sh", cb ])

import network_data as nd
from IPython.display import display, Markdown, Audio, Image
nh = home + "/store/c2gen/out/"+network_model+"/log"
    
if os.path.isfile(nh):
  with open(nh) as f:
      res = f.readlines()
      print(str.join("",res[-12:]))

  try:
    res = check_output(["tail", '-n 1', home + "/store/c2gen/nohup/"+network_model+".out"])
  except:
    try:
      res = check_output(["tail", '-n 1', home + "/store/c2gen/nohup-"+network_model+".out"])
    except:
      res = ''
  if res != '':  
    res = str(res).replace('\\n', "\n")
    res = str(res).replace('\\r', "\n")
    res = str(res).replace('\\x08', "")
    res = res.split("\n")[-1]
    print(res)


generating sample data of length:  200 
seed sequence for generation starts at frame index:  60  (approx.  0 : 3 ) 
seed sequence length: 200 
generate with frame sequences: 1 
Generated multiple frames in one action: (198, 13) 198 
wrote frames:  1 
Training Iteration 9541 
using full set of frames 
generating encoded output 
Training Iteration 9542 
using full set of frames 
generating encoded output 

525/603 [=========================>....] - ETA: 3s - loss: 0.0434 - model_2_loss_1: 1.6801 - model_2_loss_2: 1.2851 - generator_TD_Dense_0_loss: 0.0434 - model_1_loss: 0.4030'

In [690]:
with open(home + "/store/c2gen/out/"+network_model+"/config.json") as f:
    config = j = json.load(f)
    for k,v in j.items():
        print(k,": ",v)


start_iteration :  9540
num_iterations :  15000
fit_batch_size :  5
learn_next_step :  False
gen_every_nth :  10
generate_num_outputs :  2
save_model_every_nth :  10
framelen :  13
frame_seq_len :  200
overlap_sequence :  1
seed_seq_len :  200
seed_start_index :  60
seq_step :  198
test_data_fn :  test/critiquepracticalreason_00_kant_64kb.c2cb-3200
frame_prop_orig_scale :  [1, 127, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]
frame_prop_loss_scale :  [1, 127, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]
stateful :  False
shuffle :  False
limit_frames :  0
optimizer :  {'name': 'RMSprop', 'params': {}}
generate_len :  200
model_filename :  out/func-28-1-3/model-9540.h5
frame_len_ms :  20

In [691]:
try:
  with open(home + "/store/c2gen/out/" + network_model + '/notes.md', 'r') as fh:
    display(Markdown(fh.read()))
    
except:
    print("no markdown file found")


func-28-1-3 Notes

2018-01-29 15:11:06

Run with arguments test/critiquepracticalreason_00_kant_64kb.c2cb-3200 --load-weights=out/func-28-1-2/weights-15000.h5

Description

Added in two new LSTMs and reloaded weights from last run.

Disabled training on the 3 initial LSTMs and on encoder and decoder

Going well!

Restarted at 3000, having reenabled trainable flag for the initial LSTMs, allowing all LSTMs to refine themselves.

Restarted at 5450. Added 2 more LSTMs on the end, disabling the training of existing early and mid LSTMs.

Restarted at 9290 with a final wide LSTM on the end after disabling the training of all others

Didn't work due to a shape mismatch. Trying two new lstms instead of one large


In [692]:
if model_type != 'functional':
  nd.model_config(network_model)

In [693]:
nd.plot_training_loss(network_model, 'mean abs', columns=['generator_TD_Dense_0_loss', 'model_2_loss_2', 'model_2_loss_1', 'loss'], weights=[20,1,1,10], start_index=0, y_max=4)


Columns: ['generator_TD_Dense_0_loss', 'model_2_loss_2', 'model_2_loss_1', 'loss']

In [694]:
with open(home + "/store/c2gen/out/"+network_model+"/training.log") as f:
    rl = f.readlines()
    print(str.join("",rl[0:1]))
    print(str.join("",rl[-10:]))
    

with open(home + "/store/c2gen/out/"+network_model+"/gen_counter") as f:
    latest_iter = (int(f.readlines()[0]))
    print(latest_iter)


epoch,generator_TD_Dense_0_loss,loss,model_1_loss,model_2_loss_1,model_2_loss_2

0,0.0432949660355,0.0432949660355,0.403349318315,1.68153462431,1.28469138336
0,0.043070310007,0.043070310007,0.403349318315,1.67894867395,1.28469138246
0,0.0435385014275,0.0435385014275,0.403349318315,1.68267737756,1.28469138277
0,0.0432531198743,0.0432531198743,0.403349318315,1.68105472256,1.28469138351
0,0.0432481264161,0.0432481264161,0.403349318315,1.67953216334,1.28469138265
0,0.0431859599207,0.0431859599207,0.403349318315,1.68080834722,1.28469138358
0,0.0434294536734,0.0434294536734,0.403349318315,1.68174899608,1.28469138191
0,0.0436701913323,0.0436701913323,0.403349318315,1.68968350939,1.2846913827
0,0.0432196003424,0.0432196003424,0.403349318315,1.67800753457,1.28469138317
0,0.0432914788549,0.0432914788549,0.403349318315,1.68248879526,1.28469138231

9540

In [695]:
try:
  print("Latest Iteration:", latest_iter)
  
  output_fn_postfix = "output_" + str(0) + "_" + str(latest_iter)
  output_fn_postfix_mid = "output_" + str(1) + "_" + str(latest_iter)
  
  chart_postfix = output_fn_postfix

  nd.plot_codec_params(network_model,chart_postfix, scale_up='orig')
  nd.plot_codec_params(network_model,chart_postfix, scale_up='full', test_data_fn=config['test_data_fn'], test_seed_start=config['seed_start_index'])
  nd.plot_spec_params(network_model,chart_postfix, params='Voicing')
  nd.plot_spec_params(network_model,chart_postfix, params='Wo')
  nd.plot_spec_params(network_model,chart_postfix, params='E')
  nd.plot_spec_params(network_model,chart_postfix, params='LSPs', lsp_param=[0], test_data_fn=config['test_data_fn'], test_seed_start=config['seed_start_index'])
except FileNotFoundError:
    print("File not found")


Latest Iteration: 9540
3200 rate codec

3200 rate codec

Calculated diff for each parameter

In [696]:
cb = home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix)
call(["bash", home + "/store/c2gen/c2towav.sh", cb ])

try:
  nd.plot_audio_waveform(network_model, output_fn_postfix)
  display(Audio(filename=home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix)+codec_sub+".wav"))
except FileNotFoundError:
  print("file not found")
print()




In [697]:
cb = home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix_mid)
call(["bash", home + "/store/c2gen/c2towav.sh", cb ])

try:
  nd.plot_audio_waveform(network_model, output_fn_postfix_mid)
  display(Audio(filename=home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix_mid)+codec_sub+".wav"))
except FileNotFoundError:
  print("file not found")
print()



Early Iterations


In [698]:
print(output_fn_postfix1)
nd.plot_codec_params(network_model,output_fn_postfix1, scale_up='orig')
nd.plot_spec_params(network_model,output_fn_postfix1, params='Voicing')
nd.plot_spec_params(network_model,output_fn_postfix1, params='Wo')
nd.plot_spec_params(network_model,output_fn_postfix1, params='E')
nd.plot_spec_params(network_model,output_fn_postfix1, params='LSPs')


output_0_213750
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-698-8c8f3d539460> in <module>()
      1 print(output_fn_postfix1)
----> 2 nd.plot_codec_params(network_model,output_fn_postfix1, scale_up='orig')
      3 nd.plot_spec_params(network_model,output_fn_postfix1, params='Voicing')
      4 nd.plot_spec_params(network_model,output_fn_postfix1, params='Wo')
      5 nd.plot_spec_params(network_model,output_fn_postfix1, params='E')

/media/phil/Data/projects/babble-rnn/notebooks/network_data.py in plot_codec_params(network_tag, iteration, scale_up, loc, test_data_fn, test_seed_start)
     79 
     80   infilename = home + "/store/c2gen/"+loc+"/" + network_tag + fn
---> 81   indata = np.fromfile(infilename, dtype=np.uint8)
     82 
     83   if codec1300:

FileNotFoundError: [Errno 2] No such file or directory: '/home/phil/store/c2gen/out/func-28-1-3/out-c2cb-output_0_213750'

In [ ]:
nd.plot_audio_waveform(network_model, output_fn_postfix1)

Listen to the WAV file


In [ ]:
display(Audio(filename=home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix1)+codec_sub+".wav"))

In [ ]:
nd.plot_audio_waveform(network_model, output_fn_postfix1_mid)

In [ ]:
display(Audio(filename=home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix1_mid)+codec_sub+".wav"))

Later Iterations


In [ ]:
nd.plot_codec_params(network_model,output_fn_postfix2, scale_up=True)
nd.plot_spec_params(network_model,output_fn_postfix2, params='Voicing')
nd.plot_spec_params(network_model,output_fn_postfix2, params='Wo')
nd.plot_spec_params(network_model,output_fn_postfix2, params='E')
nd.plot_spec_params(network_model,output_fn_postfix2, params='LSPs')

In [ ]:
nd.plot_audio_waveform(network_model, output_fn_postfix2)

Listen to the WAV file


In [ ]:
display(Audio(filename=home + "/store/c2gen/out/"+network_model+"/out-c2cb-"+str(output_fn_postfix2)+codec_sub+".wav"))