我正在尝试在两个子图中创建子图以显示不同大小的图像.
主要图形将分为两个图 - 每个图将进一步划分为8x8子图.我不希望任何轴显示.
所以我将有两个子图,每个显示64个图像(64个子图).
看来我需要使用gridspec,但我不知道如何将axes.flatten与gridspec一起使用.axes.flatten让我在一个图上显示64个图像.
gs0 = gridspec.GridSpec(1, 2)
gs00 = gridspec.GridSpecFromSubplotSpec(8, 8, subplot_spec=gs0[0])
gs01 = gridspec.GridSpecFromSubplotSpec(8, 8, subplot_spec=gs0[1])
Run Code Online (Sandbox Code Playgroud)
我不知道如何将下面的代码与gridspec结合起来创建子图.
fig, axes = plt.subplots(nrows=8, ncols=8,figsize = (12,6))
for ax,image in zip(axes.flat,images):
ax.axes.set_axis_off()
ax.imshow(imread(image))
plt.show()
Run Code Online (Sandbox Code Playgroud) 我正在尝试将瓶颈值保存到新创建的hdf5文件中。瓶颈值成批出现(120,10,10, 2048)。单独保存一个批处理将占用超过16个演出,而python似乎在冻结该批处理。根据最近的发现(请参阅更新,看来hdf5占用大内存是可以的,但是冻结的部分似乎是一个小故障。
我只是想保存前两批用于测试目的,而只保存训练数据集(再一次,这是一次测试运行),但是我什至不能超过第一批。它只会在第一批中停顿,并且不会循环到下一个迭代。如果我尝试检查hdf5,资源管理器将变慢,Python将冻结。如果我尝试杀死Python(即使不检查hdf5文件),Python也无法正确关闭,并且会强制重启。
以下是相关的代码和数据:
总数据点约为90,000 ish,分120个批次发布。
Bottleneck shape is (120,10,10,2048)
Run Code Online (Sandbox Code Playgroud)
所以我要保存的第一批是 (120,10,10,2048)
这是我尝试保存数据集的方式:
with h5py.File(hdf5_path, mode='w') as hdf5:
hdf5.create_dataset("train_bottle", train_shape, np.float32)
hdf5.create_dataset("train_labels", (len(train.filenames), params['bottle_labels']),np.uint8)
hdf5.create_dataset("validation_bottle", validation_shape, np.float32)
hdf5.create_dataset("validation_labels",
(len(valid.filenames),params['bottle_labels']),np.uint8)
#this first part above works fine
current_iteration = 0
print('created_datasets')
for x, y in train:
number_of_examples = len(train.filenames) # number of images
prediction = model.predict(x)
labels = y
print(prediction.shape) # (120,10,10,2048)
print(y.shape) # (120, 12)
print('start',current_iteration*params['batch_size']) # 0
print('end',(current_iteration+1) * params['batch_size']) # 120
hdf5["train_bottle"][current_iteration*params['batch_size']: (current_iteration+1) * params['batch_size'],...] …Run Code Online (Sandbox Code Playgroud) 说,我有一个充满 html 链接的列表,看起来像这样:
https://www.nytimes.com/2017/05/19/realestate/they-can-afford-to-buy-but-they-would-rather-rent.html
当我在 Python 3.6 Idle 中运行脚本时,我将列表作为 Python 3.6 shell 的输出;但是,它们不可点击。有没有一种简单的方法可以使它们在外壳中可点击?
我已经用谷歌搜索过,但似乎找不到任何涉及 Python shell 的内容。
谢谢你。
我在加载模型以恢复培训时遇到问题.我在cifar数据集上使用简单的双层NN(完全连接)进行练习.
#full_connected_layers
import tensorflow as tf
import numpy as np
#input _-> hidden ->
def inference(data_samples, image_pixels, hidden_units, classes, reg_constant):
with tf.variable_scope('Layer1'):
# Define the variables
weights = tf.get_variable(
name='weights',
shape=[image_pixels, hidden_units],
initializer=tf.truncated_normal_initializer(
stddev=1.0 / np.sqrt(float(image_pixels))),
regularizer=tf.contrib.layers.l2_regularizer(reg_constant)
)
biases = tf.Variable(tf.zeros([hidden_units]), name='biases')
# Define the layer's output
hidden = tf.nn.relu(tf.matmul(data_samples, weights) + biases)
with tf.variable_scope('Layer2'):
# Define variables
weights = tf.get_variable('weights', [hidden_units, classes],
initializer=tf.truncated_normal_initializer(
stddev=1.0 / np.sqrt(float(hidden_units))),
regularizer=tf.contrib.layers.l2_regularizer(reg_constant))
biases = tf.Variable(tf.zeros([classes]), name='biases')
# Define the layer's output …Run Code Online (Sandbox Code Playgroud)