示例#1
0
def logging(model, starttime, batch_size, nb_epoch, conv_arch,dense, dropout,
            X_shape, y_shape, train_acc, val_acc, dirpath):
    now = time.ctime()
    model.save_weights('./')
    save_model(model.to_json(), now, dirpath)
    save_config(model.get_config(), now, dirpath)
    save_result(starttime, batch_size, nb_epoch, conv_arch, dense, dropout,
                    X_shape, y_shape, train_acc, val_acc, dirpath)
示例#2
0
def logging(model, starttime, batch_size, nb_epoch, conv_arch,dense, dropout,
            X_shape, y_shape, train_acc, val_acc, dirpath):
    now = time.ctime()
    model.save_weights('../data/weights/{}'.format(now))
    save_model(model.to_json(), now, dirpath)
    save_config(model.get_config(), now, dirpath)
    save_result(starttime, batch_size, nb_epoch, conv_arch, dense, dropout,
                    X_shape, y_shape, train_acc, val_acc, dirpath)
示例#3
0
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())  # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(2, activation='softmax'))

# optimizer:
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print('Training....')
model.fit(X_train, y_train, nb_epoch=nb_epoch, batch_size=batch_size,
          validation_split=0.3, shuffle=True, verbose=1)

# set callback: https://github.com/sallamander/headline-generation/blob/master/headline_generation/model/model.py

# model result:
loss_and_metrics = model.evaluate(X_train, y_train, batch_size=batch_size, verbose=1)
print ('Done!')
print ('Loss: ', loss_and_metrics[0])
print (' Acc: ', loss_and_metrics[1])

# model logging:
notes = 'medium set 100'
save_model(model.to_json(), '../data/results/')
save_config(model.get_config(), '../data/results/')
save_result(loss_and_metrics, notes, '../data/results/')
示例#4
0
print('Training....')
#With validation
#hist = model.fit(X_train, y_train, nb_epoch=nb_epoch, batch_size=batch_size
#	, validation_data=(X_val, y_val), shuffle=True, verbose=1)
#Without validation
hist = model.fit(X_train,
                 y_train,
                 nb_epoch=nb_epoch,
                 batch_size=batch_size,
                 shuffle=True,
                 verbose=1)
print(model.summary())
train_val_accuracy = hist.history
# set callback: https://github.com/sallamander/headline-generation/blob/master/headline_generation/model/model.py

# model result:
loss_and_metrics = model.evaluate(X_test,
                                  y_test,
                                  batch_size=batch_size,
                                  verbose=1)

print('Loss: ', loss_and_metrics[0])
print(' Acc: ', loss_and_metrics[1])
print(hist.history.keys())
# model logging:
notes = 'medium set 100'
save_model(model, './data/results/')
save_history(train_val_accuracy, './data/results/')
#save_config(model.get_config(), './data/results/')
save_result(train_val_accuracy, loss_and_metrics, notes, './data/results/')
示例#5
0
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(Convolution2D(128, 3, 3, border_mode='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())  # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(2, activation='softmax'))

# optimizer:
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print 'Training....'
model.fit(X_train, y_train, nb_epoch=nb_epoch, batch_size=batch_size,
          validation_split=0.3, shuffle=True, verbose=1)

# set callback: https://github.com/sallamander/headline-generation/blob/master/headline_generation/model/model.py

# model result:
loss_and_metrics = model.evaluate(X_train, y_train, batch_size=batch_size, verbose=1)
print 'Done!'
print 'Loss: ', loss_and_metrics[0]
print ' Acc: ', loss_and_metrics[1]

# model logging:
notes = 'medium set 100'
save_model(model.to_json(), '../data/results/')
save_config(model.get_config(), '../data/results/')
save_result(loss_and_metrics, notes, '../data/results/')