def getInps(spl = 0.3, Topt = np.array([1])):
    inps = ld_obj('../data/inps_RCC')
    ys = inps[0]+inps[2]
    xs = inps[1]+inps[3]
    
    xs_demo = np.stack(elt[1] for elt in xs)
        
    inps_all = ld_obj('../data/inps')
    
    new_inps = []
    for val in [1,3,5]:
        inds = []
        for elt in inps_all[val]:
            locn = np.where(np.all(elt[1] == xs_demo,axis=1))[0]
            if locn.size == 1:
                inds.append(locn[0])
        inds=np.array(inds)
        new_inps.append([bool(ys[elt]) for elt in inds])
        new_inps.append([xs[elt] for elt in inds])
        
    [trnLs, trnIms, tstLs, tstIms, valLs, valIms] = new_inps
    
    [tstImsF, tstLsF] = ld_obj('../data/inps_new_data_Fuhrman_cc.pkl')
    
    trnLs, trnIms = trnLs + tstLsF[:14], trnIms + tstImsF[:14]
    tstLs, tstIms = tstLs + tstLsF[14:28], tstIms + tstImsF[14:28]
    valLs, valIms = valLs + tstLsF[28:], valIms + tstImsF[28:]
    
    [tstImsI, tstLsI] = ld_obj('../data/inps_new_data_ISUP_cc.pkl')
    return trnLs, trnIms, tstLs, tstIms, valLs, valIms, tstLsI, tstImsI
def getInps(spl=0.3, Topt=np.array([1])):
    [trnLs, trnIms, tstLs, tstIms, valLs, valIms] = ld_obj('../data/inps')
    [tstImsF, tstLsF] = ld_obj('../data/inps_new_data_Fuhrman.pkl')

    trnLs, trnIms = trnLs + tstLsF[:14], trnIms + tstImsF[:14]
    tstLs, tstIms = tstLs + tstLsF[14:28], tstIms + tstImsF[14:28]
    valLs, valIms = valLs + tstLsF[28:], valIms + tstImsF[28:]

    [tstImsI, tstLsI] = ld_obj('../data/inps_new_data_ISUP.pkl')
    return trnLs, trnIms, tstLs, tstIms, valLs, valIms, tstLsI, tstImsI
示例#3
0
model.summary()


def with_substr(ls, sub_str):
    return [elt for elt in ls if sub_str in elt]


data_list = os.listdir('.')

input_hds = with_substr(data_list, '.hd')
input_pkls = with_substr(data_list, '.pkl')

####################

[trnIms, valIms, tstIms, trnLs, valLs, tstLs, trnDs, valDs,
 tstDs] = ld_obj(root + 'all_input_data')
#trnLs, trnIms, tstLs, tstIms, valLs, valIms = getInps()

x_train, y_train = trnIms[:, :, :, :, 0], trnLs
x_val, y_val = valIms[:, :, :, :, 0], valLs
x_tst, y_tst = tstIms[:, :, :, :, 0], tstLs

x_train = np.stack([(im - np.mean(im)) / np.std(im) for im in x_train], axis=0)
x_val = np.stack([(im - np.mean(im)) / np.std(im) for im in x_val], axis=0)
x_tst = np.stack([(im - np.mean(im)) / np.std(im) for im in x_tst], axis=0)

evl_tr = model.evaluate(x=x_train, y=y_train)
print('train: ' + str(evl_tr))

evl_vl = model.evaluate(x=x_val, y=y_val)
print('val: ' + str(evl_vl))
示例#4
0
def getInps(spl=0.3, Topt=np.array([1])):
    [trnLs, trnIms, tstLs, tstIms, valLs, valIms] = ld_obj('../data/inps')
    return trnLs, trnIms, tstLs, tstIms, valLs, valIms
示例#5
0
    )
##just nav to directory

data_list = os.listdir('.')
for elt in data_list:
    print(elt[:3] == 'all')
    print(elt[3] != '_')

print([elt for elt in data_list if ('all' == elt[:3] and (elt[3] != '_'))])
input_hds = with_substr(data_list, '.hd')
input_pkls = with_substr(data_list, '.pkl')

[
    history, mn, s, x_train, y_train, x_val, y_val, x_tst, y_tst, pred1_tr,
    pred1_vl, pred1_ts
] = ld_obj(
    [elt for elt in data_list if ('all' == elt[:3] and (elt[3] != '_'))][0])

model = LR(x_train.shape[1], 2)

chckptNm = with_substr(input_hds, 'all')[0]

model.compile(optimizer=optim,
              loss='categorical_crossentropy',
              metrics=['accuracy'])
model.load_weights(chckptNm)

evl_tr = model.evaluate(x=x_train, y=y_train)
print('train: ' + str(evl_tr))

evl_vl = model.evaluate(x=x_val, y=y_val)
print('val: ' + str(evl_vl))