我想在 Keras 中使用 InceptionV3 使用瓶颈进行迁移学习。我使用了来自https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html 的一些创建、加载和使用瓶颈的技巧
我的问题是我不知道如何使用瓶颈(numpy 数组)作为具有新顶层的 InceptionV3 的输入。
我收到以下错误:
ValueError:检查输入时出错:预期 input_3 具有形状(无、无、无、3)但得到的数组具有形状(248、8、8、2048)
在这种情况下,248 指的是图像总数。
我知道这一行是错误的,但我不知道如何更正:
模型=模型(输入=base_model.input,输出=预测)
将瓶颈输入 InceptionV3 的正确方法是什么?
创建 InceptionV3 瓶颈:
def create_bottlenecks():
datagen = ImageDataGenerator(rescale=1. / 255)
model = InceptionV3(include_top=False, weights='imagenet')
# Generate bottlenecks for all training images
generator = datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode=None,
shuffle=False)
nb_train_samples = len(generator.filenames)
bottlenecks_train = model.predict_generator(generator, int(math.ceil(nb_train_samples / float(batch_size))), verbose=1)
np.save(open(train_bottlenecks_file, 'w'), bottlenecks_train)
# Generate bottlenecks for all validation images
generator = datagen.flow_from_directory(
validation_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size, …Run Code Online (Sandbox Code Playgroud) 我试图在XSLT 2.0中编写一个尾递归函数,它迭代一个多值的日期变量并返回最早的日期.出于某种原因,我的函数不被SaxonHE9.4识别为尾递归,当输入文件超过150-200个条目时,我得到以下错误:
tail_rec_test.xsl第73行出错:嵌套函数调用太多.可能是由于无限递归.在内置模板规则中
这是我的xml输入:
<?xml version="1.0"?>
<Events>
<Event>
<Date>2004-01-01</Date>
</Event>
<Event>
<Date>2003-01-01</Date>
</Event>
<Event>
<Date>2002-01-01</Date>
</Event>
<Event>
<Date>2001-01-01</Date>
</Event>
<Event>
<Date>2005-01-01</Date>
</Event>
<Event>
<Date>2006-01-01</Date>
</Event>
<Event>
<Date>2007-01-01</Date>
</Event>
<Event>
<Date>2008-01-01</Date>
</Event>
</Events>
Run Code Online (Sandbox Code Playgroud)
这就是我的xsl文件的样子:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:own="http://ownfunctions">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:function name="own:findEarliestDate">
<xsl:param name="dates" as="xs:date*"/>
<xsl:variable name="size"><xsl:value-of select="count($dates)" /></xsl:variable>
<xsl:choose>
<xsl:when test="$size > 0">
<xsl:value-of select="own:findEarliestDate-helper($dates, $size, xs:date('2050-01-01'))" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="''"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="own:findEarliestDate-helper" as="xs:date">
<xsl:param name="items" as="xs:date*"/>
<xsl:param name="i" as="xs:integer"/> …Run Code Online (Sandbox Code Playgroud)