本文整理汇总了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
示例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)
示例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)
示例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)
示例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)