首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tensorflow / Keras CNN错误"Function call stack: distributed_function“

Tensorflow / Keras CNN错误"Function call stack: distributed_function“
EN

Stack Overflow用户
提问于 2020-07-06 22:11:20
回答 2查看 3.3K关注 0票数 1

我正在做CNN,一旦第一个时期完成,我就会收到错误消息:

代码语言:javascript
复制
"Function call stack: distributed_function"   

代码语言:javascript
复制
"Fused conv implementation does not support grouped convolutions for now."

我正在使用稍微修改过的代码,我在另一个CNN中使用的代码在前一个CNN上工作,所以我有点迷惑为什么这个错误现在会发生。

我使用的图像是类似于this的灰度热图图像

代码:

代码语言:javascript
复制
TRAINING_DIR = '/Users/me/School/Research/mini'
training_datagen = ImageDataGenerator(
    rescale = 1./255,
    rotation_range=40,
    width_shift_range=0.2,
    height_shift_range=0.2,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True,
    fill_mode='nearest')

train_generator = training_datagen.flow_from_directory(
    TRAINING_DIR,
    target_size=(640,480),
    class_mode='categorical'
)

model = tf.keras.models.Sequential([
    # Input shape is the desired size of the image 640x480 with 1 byte color
    # This is the first convolution
    tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(640, 480, 1)),
    tf.keras.layers.MaxPooling2D(2, 2), # factors to downscale by, (2,2) will halve
    tf.keras.layers.Conv2D(64, (3,3), activation='relu'),   # 2nd convo layer
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Conv2D(128, (3,3), activation='relu'),  # 3rd convo layer
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Conv2D(128, (3,3), activation='relu'),  # 4th convo layer
    tf.keras.layers.MaxPooling2D(2,2),
    tf.keras.layers.Flatten(),            # Flatten to DNN
    tf.keras.layers.Dropout(0.5),
    tf.keras.layers.Dense(512, activation='relu'),      # hidden layer 
    tf.keras.layers.Dense(3, activation='softmax')      # 3 class 
])

model.summary()
model.compile(loss = 'categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
history = model.fit(train_generator, epochs=15, verbose = 1)
model.save("rps.h5")

acc = history.history['accuracy']
loss = history.history['loss']
epochs = range(len(acc))
EN

回答 2

Stack Overflow用户

发布于 2020-07-11 13:22:03

对我来说,这是一个TensorFlow版本的问题。我使用的是2.x,而我应该使用的是1.13.2。为了修复它,我在做"import tensorflow as tf“之前做了这件事:

代码语言:javascript
复制
 !pip install tensorflow==1.13.2

这为我解决了问题。

票数 0
EN

Stack Overflow用户

发布于 2020-07-13 22:54:06

通过将input_shape=(640, 480, 1)更改为input_shape=(640, 480, 3)解决

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62757895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档