示例#1
0
 def __init__(self,tty,serialSpeed,outputPath,upthreshold=5,downthreshold=5,isThresholdRelativeToMean=True,preLength=10,postLength=120,mode='threshold'):
     self.ser=serial.Serial(tty,serialSpeed)
     self.isThresholdRelativeToMean=isThresholdRelativeToMean
     self.upthreshold=upthreshold
     self.outputPath=outputPath
     self.downthreshold=downthreshold
     self.__isReading=False
     self.__inputLisners=[]
     self.maxPlotLen=500
     self.plotY=deque([0.0]*self.maxPlotLen)
     self.plotX=np.arange(0,self.maxPlotLen)
     self.figure=plt.figure()
     self.minY=200
     self.maxY=300
     self.plt= plt.axes(xlim=(0, self.maxPlotLen), ylim=(self.minY,self.maxY))
     self.plt.grid(True)
     self.line,=self.plt.plot([],[],lw=2)
     self.mean=-1
     self.buffer=deque()
     self.inCapturing=False
     self.pre=preLength
     self.post=postLength
     self.__caputredSignalListner=[]
     self.fff=0;
     self.socketController=socketController('localhost',8080)
     init()
示例#2
0
def init(learningRate, numOfEpochs, batchSize, dimension, model_iter):
    nn.init(learningRate, numOfEpochs, batchSize, dimension, model_iter)
示例#3
0
文件: util.py 项目: kiminh/GCOMB
def init(learningRate, numOfEpochs, batchSize, dimension):
	nn.init(learningRate, numOfEpochs, batchSize, dimension)
示例#4
0
import sys
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import nn

learnRate = 0.1

if len(sys.argv) > 1:  #use given settings
    dropout = float(sys.argv[1])
    momentum = float(sys.argv[2])
    decay = float(sys.argv[3])

    (model, optimizer, criterion) = nn.init(learnRate,
                                            momentum=momentum,
                                            dropout=dropout,
                                            wd=decay)
    (accv, errv, losst) = nn.fullTrain(model, optimizer, criterion)
    testAccuracy = nn.test(model)

    print('Test Accuracy:\t' + str(testAccuracy.item() * 100.) + "%\n")

    fig, ax1 = plt.subplots()

    ax1.set_xlabel('Epochs')
    ax1.set_ylabel('Validation Error', color='tab:red')
    ax1.plot(errv, color='tab:red')
    ax1.tick_params(axis='y', labelcolor='tab:red')

    ax2 = ax1.twinx()
示例#5
0
文件: q1.py 项目: milfordn/Misc-OSU
import sys
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import nn

if len(sys.argv) < 2:
    learnRates = [1., 0.1, 0.01, 0.001, 0.0001]
else:
    learnRates = [float(sys.argv[1])]

for learnRate in learnRates:
    print("######## LEARNING RATE = " + str(learnRate) + " ########\n")
    (model, optimizer, criterion) = nn.init(learnRate)

    (accv, errv, losst) = nn.fullTrain(model, optimizer, criterion)
    testAccuracy = nn.test(model)
    print('Test Accuracy:\t' + str(testAccuracy.item() * 100.) + '%\n')

    fig, ax1 = plt.subplots()

    ax1.set_xlabel('Epochs')
    ax1.set_ylabel('Validation Error', color='tab:red')
    ax1.plot(errv, color='tab:red')
    ax1.tick_params(axis='y', labelcolor='tab:red')

    ax2 = ax1.twinx()

    ax2.set_ylabel('Training Loss', color='tab:blue')
    ax2.plot(losst, color='tab:blue')
    ax2.tick_params(axis='y', labelcolor='tab:blue')