How to use the delve.kerascallback.SaturationLogger function in delve

To help you get started, we’ve selected a few delve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github delve-team / delve / example_keras.py View on Github external
y_test = keras.utils.to_categorical(
    np.random.randint(10, size=(100, 1)), num_classes=10)

# Build model
model = Sequential()
model.add(Dense(64, input_dim=20, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(128))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(10))
model.add(Activation('softmax'))

# Delve-specific
tbCallBack = CustomTensorBoard(log_dir='./runs', user_defined_freq=1)
saturation_logger = SaturationLogger(
    model, input_data=x_train[:2], print_freq=1)

# Train and evaluate model
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)

model = Model(model.get_input_at(0), outputs=model.output)
model.compile(
    loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])

# # Optional - save to csv
# csv_logger = keras.callbacks.CSVLogger('1.log')
model.fit(
    x_train,
    y_train,
    epochs=100,
    batch_size=128,