def reading_data_and_preparing_network(files_from_cl, gpu, itera, batch_size, train_path, labels_dic, mixing, nb_groups, nb_cl, save_path): image_train, label_train,file_string = utils_data.read_data_test(train_path,labels_dic, mixing,files_from_cl=files_from_cl) image_batch, label_batch,file_string_batch = tf.train.batch([image_train, label_train,file_string], batch_size=batch_size, num_threads=8) label_batch_one_hot = tf.one_hot(label_batch,nb_groups*nb_cl) ### Network and loss function mean_img = tf.constant([123.68, 116.779, 103.939], dtype=tf.float32, shape=[1, 1, 1, 3], name='img_mean') with tf.variable_scope('ResNet18'): with tf.device('/gpu:'+gpu): scores = utils_resnet.ResNet18(image_batch-mean_img, phase='test',num_outputs=nb_cl*nb_groups) graph = tf.get_default_graph() op_feature_map = graph.get_operation_by_name('ResNet18/pool_last/avg').outputs[0] loss_class = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=label_batch_one_hot, logits=scores)) ### Initilization params = dict(cPickle.load(open(save_path+'model-iteration'+str(nb_cl)+'-%i.pickle' % itera)), 'rb') inits = utils_resnet.get_weight_initializer(params) return inits,scores,label_batch,loss_class,file_string_batch,op_feature_map
def reading_data_and_preparing_network(files_from_cl, gpu, itera, batch_size, train_path, labels_dic, mixing, nb_groups, nb_cl, save_path): image_train, label_train,file_string = utils_data.read_data_test(train_path,labels_dic, mixing,files_from_cl=files_from_cl) image_batch, label_batch,file_string_batch = tf.train.batch([image_train, label_train,file_string], batch_size=batch_size, num_threads=8) label_batch_one_hot = tf.one_hot(label_batch,nb_groups*nb_cl) ### Network and loss function mean_img = tf.constant([123.68, 116.779, 103.939], dtype=tf.float32, shape=[1, 1, 1, 3], name='img_mean') with tf.variable_scope('ResNet18'): with tf.device('/cpu:'+gpu): scores = utils_resnet.ResNet18(image_batch-mean_img, phase='test',num_outputs=nb_cl*nb_groups) graph = tf.get_default_graph() op_feature_map = graph.get_operation_by_name('ResNet18/pool_last/avg').outputs[0] loss_class = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=label_batch_one_hot, logits=scores)) ### Initilization params = dict(cPickle.load(open(save_path+'model-iteration'+str(nb_cl)+'-%i.pickle' % itera, 'rb'))) inits = utils_resnet.get_weight_initializer(params) return inits,scores,label_batch,loss_class,file_string_batch,op_feature_map