在图像调整大小插值问题中,可以在np.meshgrid对网格索引进行操作之前使用行和列索引:
nrows = 600
ncols = 800
image_in = np.random.randint(0, 256, size=(nrows, ncols, 3))
scale_factor = 1.5
r = np.arange(nrows, dtype=float) * scale_factor
c = np.arange(ncols, dtype=float) * scale_factor
rr, cc = np.meshgrid(r, c, indexing='ij')
# Nearest Neighbor Interpolation
# np.floor if scale_factor >= 1. np.ceil otherwise
rr = np.floor(rr).astype(int).clip(0, nrows-1)
cc = np.floor(cc).astype(int).clip(0, ncols-1)
image_out = image_in[rr, cc, :]
Run Code Online (Sandbox Code Playgroud)
现在,我该如何扭转这个过程呢?假设给定rr_1,cc_1( 的乘积np.meshgrid)以未知方式处理(此处用 表示np.random.randint),我如何获得r_1和c_1,即np.meshgrid(最好使用ij …
如何在客户端和服务器中使用jsonp和CORS在网页上实现跨域ajax调用.
例如,www.mytestsite.com要进行ajax调用www.otherdestinationserver.com,如何实现使用JSONP或CORS实现?
我发现了一些关于相关问题的帖子,但没有帮助。我终于弄清楚了,以下是如何读取 .json 文件的内容。假设路径是/home/xxx/dnns/test/params.json,我想把.json中的字典变成Prolog字典:
{
"type": "lenet_1d",
"input_channel": 1,
"output_size": 130,
"batch_norm": 1,
"use_pooling": 1,
"pooling_method": "max",
"conv1_kernel_size": 17,
"conv1_num_kernels": 45,
"conv1_stride": 1,
"conv1_dropout": 0.0,
"pool1_kernel_size": 2,
"pool1_stride": 2,
"conv2_kernel_size": 12,
"conv2_num_kernels": 35,
"conv2_stride": 1,
"conv2_dropout": 0.514948804688646,
"pool2_kernel_size": 2,
"pool2_stride": 2,
"fcs_hidden_size": 109,
"fcs_num_hidden_layers": 2,
"fcs_dropout": 0.8559119274655482,
"cost_function": "SmoothL1",
"optimizer": "Adam",
"learning_rate": 0.0001802763794651928,
"momentum": null,
"data_is_target": 0,
"data_train": "/home/xxx/data/20180402_L74_70mm/train_2.h5",
"data_val": "/home/xxx/data/20180402_L74_70mm/val_2.h5",
"batch_size": 32,
"data_noise_gaussian": 1,
"weight_decay": 0,
"patience": 20,
"cuda": 1,
"save_initial": 0,
"k": 4,
"save_dir": "DNNs/20181203090415_11_created/k_4"
}
Run Code Online (Sandbox Code Playgroud)