Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用notop层在tensorflow中进行微调,并定义自己的输入图像大小_Tensorflow_Keras - Fatal编程技术网

如何使用notop层在tensorflow中进行微调,并定义自己的输入图像大小

如何使用notop层在tensorflow中进行微调,并定义自己的输入图像大小,tensorflow,keras,Tensorflow,Keras,有许多关于如何使用tensorflow进行微调的示例。几乎所有这些示例都试图将图像调整为现有模型所需的指定大小。例如,224×224是vgg19需要的输入大小。但是,在keras中,我们可以通过将include_top设置为false来更改输入大小: base\u model=VGG19(包括\u top=False,weights=“imagenet”,input\u shape=(input\u size,input\u size,input\u channels)) 然后,我们不必再将图

有许多关于如何使用tensorflow进行微调的示例。几乎所有这些示例都试图将图像调整为现有模型所需的指定大小。例如,224×224是vgg19需要的输入大小。但是,在keras中,我们可以通过将include_top设置为false来更改输入大小:

base\u model=VGG19(包括\u top=False,weights=“imagenet”,input\u shape=(input\u size,input\u size,input\u channels))

然后,我们不必再将图像大小固定为224×224。我们可以通过使用tensorflow中经过正式预训练的模型来进行这种微调吗?到目前为止我还找不到解决方案,有人帮我吗?

是的,可以进行这种微调。除了最后几层(考虑更改的输出)之外,您还必须确保对原始网络的前几层(考虑更改的输入)进行微调

我使用Keras处理TensorFlow。如果您对此持开放态度,那么这里有一个代码片段显示了一般的微调流程:

具体来说,我必须编写以下代码才能使其适用于我的案例:

#img_width,img_height is the size of your new input, 3 is the number of channels
input_tensor = Input(shape=(img_width, img_height, 3))
base_model = 
keras.applications.vgg19.VGG19(include_top=False,weights='imagenet', input_tensor=input_tensor)
#instantiate whatever other layers you need
model = Model(inputs=base_model.inputs, outputs=predictions)
#predictions is the new logistic layer added to account for new classes
希望这有帮助