Ejemplo n.º 1
0
'''
Created on 05/06/2014

@author: nikolay
'''
from __builtin__ import map
import sys
import time
import collections
import logging
from os.path import os
from sys import maxint

from autoscale.FANNWrapper import FANNWrapper
from math import *



fann = FANNWrapper(topology=(1, 250, 2));

for k in range(1, 1000):
    for i in range(k, 10000, k):
        expOutput = [log(i * 10), log(i * 10)]  
        rmse = fann.train(n=i, expOutput=expOutput, trainTimes = 1, revert=False, maxRMSE=0.05)
        print "Training with i = %d, RMSE: %.4f, output=[%.4f, %.4f]" % (i, rmse, expOutput[0], expOutput[1])

for i in range(1, 10000, 100):
    result = fann.run(i)
    rmse = fann.rmse(i, result)
    print "Result: %d, RMSE: %.4f, output=[%.4f, %.4f]" % (i, rmse, result[0], result[1])
Ejemplo n.º 2
0
            rmsePart = max(1.0, rmsePre / avgRMSE)

            lrk = getLrk(k=k,
                         lr=lr,
                         rmsePart=rmsePart,
                         annPart=annPart,
                         epochCode=epochCode)
            mk = getMk(k=k, lr=lr, lrk=lrk, epochCode=epochCode)

            ek = nextEpoch(lrk=lrk, lr=lr, epochCode=epochCode)
            #             sleepPeriod = defSleepPeriod if ek < 2 else defSleepPeriod / 2.0

            # Speculated run ...
            fann.config(momentum=mk, learning_rate=lrk)
            rmsePost = fann.train(measurement.numberOfUsers(), (cpu, mem),
                                  trainTimes=1,
                                  revert=True)

            lrkBuff = lrk
            if rmsePost > rmsePre:
                lrk = lr

            fann.config(momentum=mk, learning_rate=lrk)
            fann.train(measurement.numberOfUsers(), (cpu, mem),
                       trainTimes=ek,
                       revert=False,
                       maxRMSE=None)

            values = (formatCurrTime(), server.readableName,
                      server.vmType.readableName, iteration, k,
                      measurement.numberOfUsers(), cpu, mem, ank, rmsePre,
Ejemplo n.º 3
0
            rmses.append(rmsePre)
            run = fann.run(measurement.numberOfUsers())
            
            annPart = 2**len(annomalies) * reduce(lambda x, y : x * y, map(lambda x : sigmoid(x), annomalies)) 
            rmsePart = max(1.0, rmsePre / avgRMSE)
            
            lrk = getLrk(k=k, lr=lr, rmsePart=rmsePart, annPart=annPart, epochCode = epochCode)
            mk = getMk(k=k, lr=lr, lrk = lrk, epochCode = epochCode)
            
            ek = nextEpoch(lrk=lrk, lr=lr, epochCode=epochCode)
#             sleepPeriod = defSleepPeriod if ek < 2 else defSleepPeriod / 2.0
            
            # Speculated run ...
            fann.config(momentum = mk, learning_rate = lrk)
            rmsePost=fann.train(measurement.numberOfUsers(), (cpu, mem), trainTimes=1, revert = True)
            
            lrkBuff = lrk
            if rmsePost > rmsePre:
                lrk=lr
    
            fann.config(momentum = mk, learning_rate = lrk)
            fann.train(measurement.numberOfUsers(), (cpu, mem), trainTimes=ek, revert = False, maxRMSE=None)
            
            values = (formatCurrTime(), server.readableName, server.vmType.readableName, iteration, k, measurement.numberOfUsers(),
                       cpu, mem, ank, rmsePre, run[0], run[1], ek, mk, lrk, lrkBuff, annPart, rmsePart, annPart*rmsePart, avgRMSE )
            statLine(trainingResFile, values) 
            k = k + 1
        else :
            if measurement is not None:
                txt = "SKIP: %s: [%.3d] %3d, %.5f, %.5f" % (firstAppServer.readableName, iteration, measurement.numberOfUsers(), measurement.cpuUtil(), measurement.ramUtil())