def inference_pooling_L2norm_choose_filter(images, kheight=2, kwidth=5): # channel domain pooling mapper split_dim = 1 # 1 represents split on spatial domain input_image_list = split_eeg.split_eeg_signal_axes(images, split_dim=split_dim) input_image_length = len(input_image_list) # the pooling mapper should choose half size of the image size pool_s, _ = concat_eeg.pool_eeg_signal_channel(input_image_list, input_image_length/2, 1) _print_tensor_size(pool_s) input_shape = pool_s.get_shape() range_even = tf.range(0, input_shape[0], 2) range_odd = tf.range(1, input_shape[0], 2) even_rows = tf.nn.embedding_lookup(images, range_even) odd_rows = tf.nn.embedding_lookup(images, range_odd) even_rows = tf.mul(pool_s,pool_s) even_rows = tf.mul(3.0, pool_s) even_rows = tf.nn.avg_pool(even_rows, ksize=[1, 1, 3, 1], strides=[1, 1, 3, 1], padding='VALID') pool_s = tf.sqrt(pool_s) pool_s = tf.nn.max_pool(pool_s, ksize=[1, 2, 1, 1], strides=[1, 2, 1, 1], padding='VALID') _print_tensor_size(pool_s) return pool_s
def inference_pooling_L2norm_filter(images, kwidth=5): kheight = 2 # channel domain pooling mapper split_dim = 1 # 1 represents split on spatial domain input_image_list = split_eeg.split_eeg_signal_axes(images, split_dim=split_dim) input_image_length = len(input_image_list) if input_image_length < 16: images2 = tf.nn.dropout(images, 0.85) return images2 # the pooling mapper should choose half size of the image size pool_s, _ = concat_eeg.pool_eeg_signal_channel(input_image_list, input_image_length/2, 1) _print_tensor_size(pool_s) pool_s = tf.mul(pool_s,pool_s) pool_s = tf.mul(float(kwidth), pool_s) pool_s = tf.nn.avg_pool(pool_s, ksize=[1, 1, kwidth, 1], strides=[1, 1, kwidth, 1], padding='VALID') pool_s = tf.sqrt(pool_s) pool_s = tf.nn.max_pool(pool_s, ksize=[1, 2, 1, 1], strides=[1, 2, 1, 1], padding='VALID') _print_tensor_size(pool_s) pool_s2 = tf.nn.dropout(pool_s, 0.85) return pool_s2
def inference_pooling_t_filter(images, pool_layer_scope, kheight=2, kwidth=2): # channel domain pooling mapper split_dim = 1 # 1 represents split on spatial domain input_image_list = split_eeg.split_eeg_signal_axes(images, split_dim=split_dim) input_image_length = len(input_image_list) # the pooling mapper should choose half size of the image size pool_t, _ = concat_eeg.pool_eeg_signal_channel(input_image_list, input_image_length/2, 1, is_rep=True) _print_tensor_size(pool_t) # apply the normal max pooling methods with stride = 2 pool_t = inference_pooling_n_filter(pool_t, pool_layer_scope, kheight, kwidth) return pool_t