我遵循this教程,使用Github page中的ipynb笔记本在Google Colaboratory中生成deepdream图像。本教程使用Inception5h网络。此模型中的12层通常用于生成图像。你知道吗
每一层由大约500个单独的特征组成,这些特征识别不同的模式。可以选择图层中的特定特征,从而产生不同的结果。我已经生成了第6层“mixed4a:0”中每个特征的图像。我现在要做的是混合这些特性。你知道吗
选择的特定图层如下所示:
layer_tensor = model.layer_tensors[5]
# selects layer 6 out of 12
我可以选择以下一系列功能:
layer_tensor = model.layer_tensors[5][:,:,:,0:3]
# selects feature 0 to 2 from layer 6
我要做的是选择特定的特性,而不是一系列特性。我试过几件显然不管用的事。你知道吗
layer_tensor = model.layer_tensors[5][:,:,:,0,2,4]
layer_tensor = model.layer_tensors[5][:,:,:,0:2:4]
layer_tensor = model.layer_tensors[5][:,:,:,[0,2,4]]
layer_tensor = model.layer_tensors[5][:,:,:,[0:2:4]]
layer_tensor = model.layer_tensors[5][:,:,:,(0,2,4)]
为了弄清楚“层张量”是什么样的对象/对象/数据结构,我尝试用不同的参数打印它:
layer_tensor = model.layer_tensors[5]
# prints Tensor("mixed4a:0", shape=(?, ?, ?, 508), dtype=float32, device=/device:CPU:0)
# "mixed4a:0" is the layer name. 508 in 'shape' is the number of features in the layer
layer_tensor = model.layer_tensors[5][:,:,:,0:100]
# prints: Tensor("strided_slice_127:0", shape=(?, ?, ?, 100), dtype=float32)
layer_tensor = model.layer_tensors[5][:,:,:,0]
# prints: Tensor("strided_slice_128:0", shape=(?, ?, ?), dtype=float32)
我是张量流和神经网络的新手。有人知道如何选择不同的功能,而不仅仅是一系列的功能吗?提前谢谢!你知道吗
要运行代码,请使用_张量流.ipynb'文件到谷歌实验室。选择带有GPU后端的Python3运行时。上传文件的下载.py'和'inception5h.py'进入运行时,它应该可以正常工作。你知道吗
您可以使用tf.gather通过以下方式实现所需的功能。你知道吗
它看起来很复杂,但它所做的只是跟随。你知道吗
layer_tensor
s.t.最后一个轴(即您要切片的轴)是第一个轴(因为这样可以更容易地进行切片)tf.gather
进行切片。我们采用1,3,5特征。它可能是一个索引列表希望这是清楚的。你知道吗
相关问题 更多 >
编程相关推荐