예제 #1
0
파일: test.py 프로젝트: sadeghst/geolearn
                                         subset='CONUSv4f1',
                                         tRange=ty2)
    x = df.getDataTs(dbCsv.varForcing, doNorm=True, rmNan=True)
    c = df.getDataConst(dbCsv.varConst, doNorm=True, rmNan=True)
    nx = x.shape[-1] + c.shape[-1]
    yT = df.getDataTs('SMAP_AM', doNorm=False, rmNan=False)
    yT = yT[:, :, 0]

    # test
    ypLstmLst = list()
    ypAnnLst = list()
    modelName = 'LSTM'
    model = train.loadModel(outFolder, 100, modelName=modelName)
    yp = train.testModel(model, x, c, batchSize=100).squeeze()
    ypLstmLst.append(
        dbCsv.transNorm(yp, rootDB=rootDB, fieldName='SMAP_AM', fromRaw=False))
    for k in dLst:
        sd = utils.time.t2dt(ty2[0]) - dt.timedelta(days=k)
        ed = utils.time.t2dt(ty2[1]) - dt.timedelta(days=k)
        df2 = hydroDL.data.dbCsv.DataframeCsv(rootDB=rootDB,
                                              subset='CONUSv4f1',
                                              tRange=[sd, ed])
        obs = df2.getDataTs('SMAP_AM', doNorm=True, rmNan=False)

        modelName = 'LSTM-DA-' + str(k)
        model = train.loadModel(outFolder, nEpoch, modelName=modelName)
        yP = train.testModel(model, (x, obs), c, batchSize=100).squeeze()
        ypLstmLst.append(
            dbCsv.transNorm(yP,
                            rootDB=rootDB,
                            fieldName='SMAP_AM',
예제 #2
0
x = df.getData(varT=dbCsv.varForcing,
               varC=dbCsv.varConst,
               doNorm=True,
               rmNan=True)
y = df.getData(varT='SMAP_AM', doNorm=True, rmNan=False)
nx = x.shape[-1]
ny = 1

model = rnn.CnnCondLstm(nx=nx, ny=ny, ct=365, hiddenSize=64, cnnSize=32, opt=3)
lossFun = crit.RmseLoss()
model = train.trainModel(model,
                         x,
                         y,
                         lossFun,
                         xc=c,
                         nEpoch=nEpoch,
                         miniBatch=[100, 30])

yOut = train.testModelCnnCond(model, x, y)
# yOut = train.testModel(model, x)
yP = dbCsv.transNorm(yOut[:, :, 0],
                     rootDB=rootDB,
                     fieldName='SMAP_AM',
                     fromRaw=False)
yT = dbCsv.transNorm(y[:, model.ct:, 0],
                     rootDB=rootDB,
                     fieldName='SMAP_AM',
                     fromRaw=False)
statDict = post.statError(yP, yT)
statDict['RMSE'].mean()