def saveweight(str, n):
    #save
    tntn = []
    tntn = n.ni - 1, n.nh - 1, n.nh2 - 1, n.no

    txtx = []
    txtx = n.wi, n.wo, n.wo2

    tgtg = []
    tgtg.append(tntn)
    tgtg.append(txtx)

    print 'save...'
    print tgtg
    print '...save'
    dewweight.dew_write_weight_file(str, tgtg)
def demoClassification():
    # Teach network XOR function
    #pat = [
    #    [[0,0], [0]],
    #    [[0,1], [1]],
    #    [[1,0], [1]],
    #    [[1,1], [0]]
    #]

    print "loading training.txt"
    pat = dewload.dew_load_train_file("./txt/training.txt")
    print "pat = "
    print pat
    pat2 = dewnormal.dew_normal_big_set_for_ol(pat)

    print "paterrn from Training.txt"
    print pat2

    # create a network with two input, two hidden, and one output nodes
    n = NN(67, 38, 8, regression = False)

    #load and retrain
    #n.wi, n.wo = loadweight("./txt/weight_1.txt",n)
    # train it with some patterns then test it.
    #print pat2
    n.train(pat2, 100, 0.1, 0.2)

    #n.test(pat2, verbose = True)
    n.weights()

    #save
    txtx = []
    txtx = n.wi , n.wo
    dewweight.dew_write_weight_file("./txt/weight_1.txt",txtx)

    #predict = [
#	[[1,0],[1]]
#    ]
 #   n.test(predict, verbose = True)

    try:
        plot(inputs, outputs, actual)
        #plot(pat, pat, pat)
        print "Press a key to quit."
        value = raw_input()
    except:
        print "Must have matplotlib to plot."
def saveweight(str,n):
    #save
    txtx = []
    txtx = n.wi , n.wo
    dewweight.dew_write_weight_file(str,txtx)