def construct_weights(self, scope=''): weights = {} dtype = tf.float32 conv_initializer = tf.contrib.layers.xavier_initializer_conv2d(dtype=dtype) fc_initializer = tf.contrib.layers.xavier_initializer(dtype=dtype) k = 5 if not FLAGS.cclass: classes = 1 else: classes = self.label_size with tf.variable_scope(scope): init_conv_weight(weights, 'c1_pre', 3, self.channels, self.dim_hidden) init_res_weight(weights, 'res_optim', 3, self.dim_hidden, self.dim_hidden, classes=classes) init_res_weight(weights, 'res_1', 3, self.dim_hidden, 2*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_2', 3, 2*self.dim_hidden, 2*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_3', 3, 2*self.dim_hidden, 2*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_4', 3, 2*self.dim_hidden, 4*self.dim_hidden, classes=classes) # init_fc_weight(weights, 'fc_dense', 4*4*4*self.dim_hidden, 2*self.dim_hidden) init_fc_weight(weights, 'fc_dense', 4*self.dim_hidden, 2*self.dim_hidden) init_fc_weight(weights, 'fc5', 4*self.dim_hidden, 1, spec_norm=False) return weights
def construct_weights(self, scope=''): weights = {} dtype = tf.float32 if not FLAGS.cclass: classes = 1 else: classes = self.classes print("constructing weights with class number ", classes) with tf.variable_scope(scope): # First block init_conv_weight(weights, 'c1_pre', 3, self.channels, 64) init_res_weight(weights, 'res_optim', 3, 64, self.dim_hidden, classes=classes) init_res_weight(weights, 'res_3', 3, self.dim_hidden, 2*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_5', 3, 2*self.dim_hidden, 4*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_7', 3, 4*self.dim_hidden, 8*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_9', 3, 8*self.dim_hidden, 8*self.dim_hidden, classes=classes) init_res_weight(weights, 'res_10', 3, 8*self.dim_hidden, 8*self.dim_hidden, classes=classes) init_fc_weight(weights, 'fc5', 8*self.dim_hidden , 1, spec_norm=False) init_attention_weight(weights, 'atten', self.dim_hidden, self.dim_hidden / 2., trainable_gamma=True) return weights
def construct_weights(self, scope=''): weights = {} dtype = tf.float32 conv_initializer = tf.contrib.layers.xavier_initializer_conv2d(dtype=dtype) fc_initializer = tf.contrib.layers.xavier_initializer(dtype=dtype) classes = 1 with tf.variable_scope(scope): init_conv_weight(weights, 'c1_pre', 1, self.channels, 64, spec_norm=False) init_conv_weight(weights, 'c1', 4, 64, self.dim_hidden, classes=classes, spec_norm=False) init_conv_weight(weights, 'c2', 4, self.dim_hidden, 2*self.dim_hidden, classes=classes, spec_norm=False) init_conv_weight(weights, 'c3', 4, 2*self.dim_hidden, 4*self.dim_hidden, classes=classes, spec_norm=False) init_conv_weight(weights, 'c4', 4, 4*self.dim_hidden, 4*self.dim_hidden, classes=classes, spec_norm=False) init_fc_weight(weights, 'fc_dense_pos', 4*self.dim_hidden, 2*self.dim_hidden, spec_norm=False) init_fc_weight(weights, 'fc_dense_logit', 4*self.dim_hidden, 2*self.dim_hidden, spec_norm=False) init_fc_weight(weights, 'fc5_pos', 2*self.dim_hidden, 2, spec_norm=False) init_fc_weight(weights, 'fc5_logit', 2*self.dim_hidden, 1, spec_norm=False) return weights