示例#1
0
import NN_io

if __name__ == '__main__':

    usage='%prog [options] in.const.NN in.params.NN'
    parser= optparse.OptionParser(usage=usage)
    (options,args)= parser.parse_args()

    if len(args) != 2:
        print usage
        sys.exit()

    incnst= args[0]
    inprms= args[1]

    nl,nsp,nhl,itypes,combs,consts= NN_io.read_const(incnst)
    nprm,rcut,rcut3,prms= NN_io.read_params(inprms)
    
    #.....print current configuration
    print " Current NN configuration:"
    print "   Num of layers = ",nl
    print "   Num of nodes in layers = ",
    for il in range(nl+1):
        print " {0:d}:{1:d}".format(il,nhl[il]),
    print ""

    #.....read new configuration
    print ""
    print " Let's decide new NN configuration."
    print ""
    print " Please enter new number of hidden layers:"
示例#2
0
if __name__ == '__main__':

    usage= '%prog [options] in.const.NN in.params.NN out.NN_analysis'

    parser= optparse.OptionParser(usage=usage)
    parser.add_option("-t","--threshold",dest="threshold",type="float",
                      default=1e-8,
                      help="Threshold value less than which are to be elminiated.")
    (options,args)= parser.parse_args()

    threshold= options.threshold
    incnst= args[0]
    inprms= args[1]
    innnanal= args[2]

    nl,nsp,nhl,itypes,combs,consts= NN_io.read_const(incnst)
    nprm,rcut,rcut3,prms= NN_io.read_params(inprms)
    nnanal= NN_io.read_NN_analysis(innnanal)
    
    if nhl[0] != len(nnanal):
        print('[Error] nhl[0] != len(nnanal)')
        print('  nhl[0],len(nnanal)=',nhl[0],len(nnanal))
        exit()

    focnst= open(outcnst,'w')
    foprms= open(outprms,'w')
    #...count number of bases to be remained
    nsfnew= 0
    for ihl0 in range(nhl[0]):
        if nnanal[ihl0][1] > threshold:
            nsfnew += 1