Пример #1
0
def get_model():
    return ipu.keras.Sequential(
        [Embedding(256, 128),
         LSTM(EMBEDDING_DIM, return_sequences=True),
         LSTM(EMBEDDING_DIM, return_sequences=True),
         TimeDistributed(Dense(256, activation='softmax'))],
        accumulation_count = REPEAT_COUNT)
Пример #2
0
def get_model():
    input_layer = Input(shape=(80), dtype=tf.int32, batch_size=minibatch_size)

    x = Embedding(max_features, 128)(input_layer)
    x = LSTM(128, dropout=0.2)(x)
    x = Dense(16, activation='relu')(x)
    x = Dense(1, activation='sigmoid')(x)

    return ipu.keras.Model(input_layer, x)
Пример #3
0
def get_model():
    input_layer = Input(shape=(80), dtype=tf.int32, batch_size=minibatch_size)

    with ipu.keras.PipelineStage(0):
        x = Embedding(max_features, 128)(input_layer)

    with ipu.keras.PipelineStage(1):
        x = LSTM(128, dropout=0.2)(x)
        x = Dense(1, activation='sigmoid')(x)

    return ipu.keras.PipelineModel(
        input_layer,
        x,
        gradient_accumulation_count=gradient_accumulation_count)
Пример #4
0
def get_model():
    input_layer = Input(shape=(80), dtype=dtypes.int32, batch_size=32)

    with ipu.keras.PipelineStage(0):
        x = Embedding(max_features, 128)(input_layer)
        x = LSTM(128, dropout=0.2)(x)

    with ipu.keras.PipelineStage(1):
        a = Dense(16, activation='relu')(x)

    with ipu.keras.PipelineStage(2):
        b = Dense(16, activation='relu')(x)

    with ipu.keras.PipelineStage(3):
        x = Concatenate()([a, b])
        x = Dense(1, activation='sigmoid')(x)

    return ipu.keras.PipelineModel(input_layer,
                                   x,
                                   gradient_accumulation_count=16,
                                   device_mapping=[0, 1, 1, 0])
Пример #5
0
def get_model():
    return ipu.keras.SequentialPipelineModel(
        [[Embedding(max_features, 128)],
         [LSTM(128, dropout=0.2),
          Dense(1, activation='sigmoid')]],
        gradient_accumulation_count=gradient_accumulation_count)
Пример #6
0
def get_model():
    return ipu.keras.Sequential([
        Embedding(max_features, 128),
        LSTM(128, dropout=0.2),
        Dense(1, activation='sigmoid')
    ])
Пример #7
0
def get_model():
    return ipu.keras.PipelinedModel(
        [[Embedding(max_features, 128)],
         [LSTM(128, dropout=0.2),
          Dense(1, activation='sigmoid')]],
        pipeline_depth=pipeline_depth)