當前位置: 首頁>>代碼示例>>Python>>正文


Python tensor.tensor5方法代碼示例

本文整理匯總了Python中theano.tensor.tensor5方法的典型用法代碼示例。如果您正苦於以下問題:Python tensor.tensor5方法的具體用法?Python tensor.tensor5怎麽用?Python tensor.tensor5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在theano.tensor的用法示例。


在下文中一共展示了tensor.tensor5方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fSPP

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import tensor5 [as 別名]
def fSPP(inp, level=3):
    inshape = inp._keras_shape[2:]
    Kernel = [[0] * 3 for i in range(level)]
    Stride = [[0] * 3 for i in range(level)]
    SPPout = T.tensor5()
    for iLevel in range(level):
        Kernel[iLevel] = np.ceil(np.divide(inshape, iLevel+1, dtype = float)).astype(int)
        Stride[iLevel] = np.floor(np.divide(inshape, iLevel+1, dtype = float)).astype(int)
        if inshape[2]%3==2:
            Kernel[2][2] = Kernel[2][2] + 1
        poolLevel = MaxPooling3D(pool_size=Kernel[iLevel], strides=Stride[iLevel])(inp)
        if iLevel == 0:
            SPPout = Flatten()(poolLevel)
        else:
            poolFlat = Flatten()(poolLevel)
            SPPout = concatenate([SPPout,poolFlat], axis=1)
    return SPPout


# Models of FCN 
開發者ID:thomaskuestner,項目名稱:CNNArt,代碼行數:22,代碼來源:MSnetworks.py

示例2: __init__

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import tensor5 [as 別名]
def __init__(self, generator, obs, num_samples, sigma, hdim, L, epsilon, prior, init_state=None):
        self.generator = generator
        self.batch_size = obs.shape[0]
        self.obs_val = sharedX(np.reshape(obs,[1,self.batch_size,3,32,32]))
        #ftensor5 = TensorType('float32', (False,)*5)
        #self.obs = ftensor5()
        self.obs = T.tensor5()
        #pdb.set_trace()
        self.t = T.scalar()
        self.sigma = sigma
        self.n_sam = num_samples
        self.hdim = hdim
        self.L = L
        self.eps = epsilon
        self.prior = prior
        if init_state is None:
            self.build(self.eps, self.L)
        else:
            self.build(self.eps, self.L,init_state = init_state) 
開發者ID:tonywu95,項目名稱:eval_gen,代碼行數:21,代碼來源:svhn_samplers.py

示例3: run

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import tensor5 [as 別名]
def run(fold=0):
    print fold
    I_AM_FOLD = fold
    all_data = load_dataset(folder=paths.preprocessed_testing_data_folder)

    use_patients = all_data
    experiment_name = "final"
    results_folder = os.path.join(paths.results_folder, experiment_name,
                                  "fold%d"%I_AM_FOLD)
    write_images = False
    save_npy = True

    INPUT_PATCH_SIZE =(None, None, None)
    BATCH_SIZE = 2
    n_repeats=3
    num_classes=4

    x_sym = T.tensor5()

    net, seg_layer = build_net(x_sym, INPUT_PATCH_SIZE, num_classes, 4, 16, batch_size=BATCH_SIZE,
                               do_instance_norm=True)
    output_layer = seg_layer

    results_out_folder = os.path.join(results_folder, "pred_test_set")
    if not os.path.isdir(results_out_folder):
        os.mkdir(results_out_folder)

    with open(os.path.join(results_folder, "%s_Params.pkl" % (experiment_name)), 'r') as f:
        params = cPickle.load(f)
        lasagne.layers.set_all_param_values(output_layer, params)

    print "compiling theano functions"
    output = softmax_helper(lasagne.layers.get_output(output_layer, x_sym, deterministic=False,
                                                      batch_norm_update_averages=False, batch_norm_use_averages=False))
    pred_fn = theano.function([x_sym], output)
    _ = pred_fn(np.random.random((BATCH_SIZE, 4, 176, 192, 176)).astype(np.float32))

    run_validation_mirroring(pred_fn, results_out_folder, use_patients, write_images=write_images, hasBrainMask=False,
                             BATCH_SIZE=BATCH_SIZE, num_repeats=n_repeats, preprocess_fn=preprocess, save_npy=save_npy,
                             save_proba=False) 
開發者ID:MIC-DKFZ,項目名稱:BraTS2017,代碼行數:42,代碼來源:predict_test_set.py

示例4: run

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import tensor5 [as 別名]
def run(fold=0):
    print fold
    I_AM_FOLD = fold
    all_data = load_dataset(folder=paths.preprocessed_validation_data_folder)

    use_patients = all_data
    experiment_name = "final"
    results_folder = os.path.join(paths.results_folder, experiment_name,
                                  "fold%d"%I_AM_FOLD)
    write_images = False
    save_npy = True

    INPUT_PATCH_SIZE =(None, None, None)
    BATCH_SIZE = 2
    n_repeats=2
    num_classes=4

    x_sym = T.tensor5()

    net, seg_layer = build_net(x_sym, INPUT_PATCH_SIZE, num_classes, 4, 16, batch_size=BATCH_SIZE,
                               do_instance_norm=True)
    output_layer = seg_layer

    results_out_folder = os.path.join(results_folder, "pred_val_set")
    if not os.path.isdir(results_out_folder):
        os.mkdir(results_out_folder)

    with open(os.path.join(results_folder, "%s_Params.pkl" % (experiment_name)), 'r') as f:
        params = cPickle.load(f)
        lasagne.layers.set_all_param_values(output_layer, params)

    print "compiling theano functions"
    output = softmax_helper(lasagne.layers.get_output(output_layer, x_sym, deterministic=False,
                                                      batch_norm_update_averages=False, batch_norm_use_averages=False))
    pred_fn = theano.function([x_sym], output)
    _ = pred_fn(np.random.random((BATCH_SIZE, 4, 176, 192, 176)).astype(np.float32))

    run_validation_mirroring(pred_fn, results_out_folder, use_patients, write_images=write_images, hasBrainMask=False,
                             BATCH_SIZE=BATCH_SIZE, num_repeats=n_repeats, preprocess_fn=preprocess, save_npy=save_npy,
                             save_proba=False) 
開發者ID:MIC-DKFZ,項目名稱:BraTS2017,代碼行數:42,代碼來源:predict_val_set.py

示例5: run

# 需要導入模塊: from theano import tensor [as 別名]
# 或者: from theano.tensor import tensor5 [as 別名]
def run(fold=0):
    print fold
    I_AM_FOLD = fold

    all_data = load_dataset()
    keys_sorted = np.sort(all_data.keys())

    crossval_folds = KFold(len(all_data.keys()), n_folds=5, shuffle=True, random_state=123456)

    ctr = 0
    for train_idx, test_idx in crossval_folds:
        print len(train_idx), len(test_idx)
        if ctr == I_AM_FOLD:
            test_keys = [keys_sorted[i] for i in test_idx]
            break
        ctr += 1

    validation_data = {i:all_data[i] for i in test_keys}


    use_patients = validation_data
    EXPERIMENT_NAME = "final"
    results_folder = os.path.join(paths.results_folder,
                               EXPERIMENT_NAME,  "fold%d" % I_AM_FOLD)
    write_images = False
    save_npy = True

    INPUT_PATCH_SIZE =(None, None, None)
    BATCH_SIZE = 2
    n_repeats=2
    num_classes=4

    x_sym = T.tensor5()

    net, seg_layer = build_net(x_sym, INPUT_PATCH_SIZE, num_classes, 4, 16, batch_size=BATCH_SIZE,
                                           do_instance_norm=True)
    output_layer = seg_layer

    results_out_folder = os.path.join(results_folder, "validation")
    if not os.path.isdir(results_out_folder):
        os.mkdir(results_out_folder)

    with open(os.path.join(results_folder, "%s_Params.pkl" % (EXPERIMENT_NAME)), 'r') as f:
        params = cPickle.load(f)
        lasagne.layers.set_all_param_values(output_layer, params)

    print "compiling theano functions"
    output = softmax_helper(lasagne.layers.get_output(output_layer, x_sym, deterministic=False,
                                                      batch_norm_update_averages=False, batch_norm_use_averages=False))
    pred_fn = theano.function([x_sym], output)
    _ = pred_fn(np.random.random((BATCH_SIZE, 4, 176, 192, 176)).astype(np.float32))  # preallocate memory on GPU

    run_validation_mirroring(pred_fn, results_out_folder, use_patients, write_images=write_images, hasBrainMask=False,
                             BATCH_SIZE=BATCH_SIZE, num_repeats=n_repeats, preprocess_fn=preprocess, save_npy=save_npy) 
開發者ID:MIC-DKFZ,項目名稱:BraTS2017,代碼行數:56,代碼來源:validate_network.py


注:本文中的theano.tensor.tensor5方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。