def main(): direc_data = '/data/npz_data/cells/unspecified_nuclear_data/nuclear_movie/' dataset = 'nuclear_movie_same' training_data = np.load('{}{}.npz'.format(direc_data, dataset)) optimizer = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) lr_sched = rate_scheduler(lr=0.01, decay=0.99) in_shape = (14, 14, 1) model = the_model(input_shape=in_shape) #, n_features=1, reg=1e-5) train_model_siamese( model=model, dataset='nuclear_movie_same', optimizer=optimizer, expt='', it=0, batch_size=1, n_epoch=100, direc_save='/data/models/cells/unspecified_nuclear_data/nuclear_movie', direc_data= '/data/npz_data/cells/unspecified_nuclear_data/nuclear_movie/', lr_sched=lr_sched, rotation_range=0, flip=True, shear=0, class_weight=None)
def train_model_on_training_data(): direc_save = os.path.join(MODEL_DIR, PREFIX) direc_data = os.path.join(NPZ_DIR, PREFIX) training_data = np.load(os.path.join(direc_data, DATA_FILE + '.npz')) class_weights = training_data['class_weights'] X, y = training_data['X'], training_data['y'] print('X.shape: {}\ny.shape: {}'.format(X.shape, y.shape)) n_epoch = 100 batch_size = 32 if DATA_OUTPUT_MODE == 'sample' else 1 optimizer = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) lr_sched = rate_scheduler(lr=0.01, decay=0.99) model_args = {'norm_method': 'median', 'reg': 1e-5, 'n_features': 3} data_format = K.image_data_format() row_axis = 2 if data_format == 'channels_first' else 1 col_axis = 3 if data_format == 'channels_first' else 2 channel_axis = 1 if data_format == 'channels_first' else 3 if DATA_OUTPUT_MODE == 'sample': train_model = train_model_sample the_model = bn_feature_net_61x61 model_args['n_channels'] = 1 elif DATA_OUTPUT_MODE == 'conv' or DATA_OUTPUT_MODE == 'disc': train_model = train_model_conv the_model = bn_dense_feature_net model_args['location'] = False size = (RESHAPE_SIZE, RESHAPE_SIZE) if RESIZE else X.shape[row_axis:col_axis + 1] if data_format == 'channels_first': model_args['input_shape'] = (X.shape[channel_axis], size[0], size[1]) else: model_args['input_shape'] = (size[0], size[1], X.shape[channel_axis]) model = the_model(**model_args) train_model(model=model, dataset=DATA_FILE, optimizer=optimizer, batch_size=batch_size, n_epoch=n_epoch, direc_save=direc_save, direc_data=direc_data, lr_sched=lr_sched, class_weight=class_weights, rotation_range=180, flip=True, shear=True)
import numpy as np batch_size = 1 n_epoch = 100 dataset = "nuclei_broad_same_conv_61x61" expt = "bn_dense_feature_net" direc_save = "/data/trained_networks/nuclei_broad/" direc_data = "/data/training_data_npz/nuclei_broad/" # Create output ditrectory, if necessary pathlib.Path(direc_save).mkdir(parents=True, exist_ok=True) optimizer = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) lr_sched = rate_scheduler(lr=0.01, decay=0.99) file_name = os.path.join(direc_data, dataset + ".npz") training_data = np.load(file_name) class_weights = training_data["class_weights"] for iterate in range(1): model = the_model(batch_shape=(1, 512, 512, 1), n_features=3, reg=1e-5, softmax=True, permute=True) train_model(model=model, dataset=dataset,
from scipy.misc import imsave batch_size = 1 n_epoch = 50 dataset = "nuclear_movie_disc_same" expt = "bn_dense_net_3D" direc_save = "/data/trained_networks/nuclear_movie/" direc_data = "/data/training_data_npz/nuclear_movie/" # Create output ditrectory, if necessary pathlib.Path(direc_save).mkdir(parents=True, exist_ok=True) optimizer = SGD(lr=1e-2, decay=1e-6, momentum=0.9, nesterov=True) lr_sched = rate_scheduler(lr=1e-2, decay=0.99) file_name = os.path.join(direc_data, dataset + ".npz") training_data = np.load(file_name) for iterate in range(1): model = the_model(batch_shape=(1, 1, 5, 256, 256), n_features=3, reg=1e-5, location=False, permute=True, softmax=False) trained_model = train_model(model=model, dataset=dataset,