Keras(TF后端)在创建LSTM时出现分段错误

时间:2018-01-10 23:21:24

标签: linux tensorflow keras bidirectional

我正在尝试使用MacBook Pro和iMac计算机上的标准深度学习模型,然后再将它们放在Linux GPU服务器上运行。我在py27 conda环境中处理所有这些系统。在所有系统上使用最新版本的Keras和Tensorflow(但由于服务器是linux机器并且还有张量flow-gpu版本,因此不同的发行版)。当我运行简单的CNN时,在所有平台上,从构建到培训都很有效。但是,尝试RNN,我在模型构建点的linux服务器上获得Segmentation Fault,我在其中添加了一个双向(LSTM或GRU)层。相同的代码在我的两个Mac系统上运行完美。我很困惑,因为CNN在Linux服务器的GPU上运行良好,tensorflow-gpu linux发行版中是否存在与周期性图层相关的错误?

  • Linux服务器(Ubuntu 16.04.3):tensorflow-gpu 1.3.0和Keras 2.1.2
  • Mac系统(两种不同的操作系统):tensorflow 1.1.0和Keras 2.1.2

def prepare_rnn_model_1(word_index, embedding_matrix):
    print("*** 1")
    embedding_layer = Embedding(len(word_index) + 1,
                                EMBEDDING_DIM,
                                weights=[embedding_matrix],
                                input_length=MAX_SEQUENCE_LENGTH,
                                trainable=True)

    print("*** 2")
    sequence_input = Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32')
    print("*** 3")
    embedded_sequences = embedding_layer(sequence_input)
    print("*** 4")
    l_lstm = Bidirectional(LSTM(100))(embedded_sequences)
    print("*** 5")
    preds = Dense(CLASSES, activation='softmax')(l_lstm)
    print("*** 6")
    model = Model(sequence_input, preds)
    print("*** 7")
    model.compile(loss='categorical_crossentropy',
                  optimizer='rmsprop',
                  metrics=['acc'])
    return model

0 个答案:

没有答案
相关问题