def generate_spec(model, mlp, mgc, out_spec, fea_size):
    fin = open(model)
    print 'load ae..'
    ae = cPickle.load(fin)
    fin.close()

    fin = open(mlp)
    print 'load mlp..'
    mlp = cPickle.load(fin)
    fin.close()

    mgc_fin = open(mgc)
    print 'open ', mgc
    mgc = np.fromfile(mgc_fin, dtype='<f4')
    assert mgc.shape[0] % fea_size == 0
    mgc = mgc.reshape((fea_size/mgc.shape[0], fea_size))
    print 'mgc shape ', mgc.shape
    decoded = ae.decode(mgc)

    normalizer = mlp.fprop(decoded)
    print 'normalizer shape ', normalizer.shape
    # import pdb
    # pdb.set_trace()
    warp_spec = decoded * normalizer
    fout = open(out_spec, 'wb')
    print 'saving.. '
    warp_spec.tofile(fout, format='<f8')

    mgc_fin.close()
    fout.close()
    print 'done'
dataset/ETHPy150Open hycis/Pynet/scripts/tmp.py/generate_spec/swapped operands of `/`