You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
Thanks a lot for making morphnet open source. I wish to try it out but it seems I am having some trouble with getting it to work.
I have multiple outputs from my network. I am using the GroupLassoFlopsRegularizer and it seems to give me an error when i pass it a list of logits which come out of my network.
My network
self.outputs_softmax_a= Softmax()(logits_a)
self.outputs_softmax_b = Softmax()(logits_b)
self.outputs_softmax_c = Softmax()(logits_c)
self.outputs_softmax_d = Softmax()(logits_d)
self.network_regularizer = flop_regularizer.GroupLassoFlopsRegularizer(
[logits_a.op, logits_b.op, logits_c.op, logits_d.op], threshold=1e-3)
self.exporter = structure_exporter.StructureExporter(
self.network_regularizer.op_regularizer_manager)
self.regularization_strength = 1e-10
with tf.name_scope("loss"):
neg_log_prob_a = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits_a, labels=self.out_a)
neg_log_prob_b = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits_b, labels=self.out_b)
neg_log_prob_c = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits_c, labels=self.out_c)
neg_log_prob_d = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits_d, labels=self.out_d)
loss_a = tf.reduce_mean(neg_log_prob_a * self.discounted_episode_rewards_norm) # reward guided loss
loss_b = tf.reduce_mean(neg_log_prob_b * self.discounted_episode_rewards_norm) # reward guided loss
loss_c = tf.reduce_mean(neg_log_prob_c * self.discounted_episode_rewards_norm) # reward guided loss
loss_d = tf.reduce_mean(neg_log_prob_d * self.discounted_episode_rewards_norm) # reward guided loss
self.regularizer_loss = (self.network_regularizer.get_regularization_term() *
self.regularization_strength)
self.loss = loss_a + loss_b + loss_c + loss_d + self.regularizer_loss
with tf.name_scope("train"):
#update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
train_ops = tf.train.AdamOptimizer(self.lr).minimize(self.loss)
self.train_op = tf.group([train_ops])#, update_ops])
self.setup_writer() # has to be before global variables initializer inside the graph for write_op to be
# populated
self.init = tf.global_variables_initializer()`
The error i get when i run my script that instantiates the model
File "/home/ubuntu/morph_basic/basic_bline.py", line 78, in build_model [logits_a.op, logits_b.op, logits_c.op, logits_d.op], threshold=1e-3) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/network_regularizers/flop_regularizer.py", line 153, in __init__ regularizer_blacklist=regularizer_blacklist) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_regularizer_manager.py", line 126, in __init__ self._op_handler_dict[op.type].assign_grouping(op, self) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/grouping_op_handler.py", line 40, in assign_grouping output_ops, op_reg_manager) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_handler_util.py", line 73, in get_ops_without_groups op_slices = op_reg_manager.get_op_slices(op) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_regularizer_manager.py", line 438, in get_op_slices if size > 0: TypeError: '>' not supported between instances of 'NoneType' and 'int'
The text was updated successfully, but these errors were encountered:
Hi
Thanks a lot for making morphnet open source. I wish to try it out but it seems I am having some trouble with getting it to work.
I have multiple outputs from my network. I am using the GroupLassoFlopsRegularizer and it seems to give me an error when i pass it a list of logits which come out of my network.
My network
`
def build_model(self):
self.g = tf.Graph()
with self.g.as_default():
tf.set_random_seed(42)
self.inputs = tf.placeholder(tf.float32, [None, *(self.state_size)], name="inputs_")
print(self.inputs)
self.out_a = tf.placeholder(tf.int32, [None, ], name="out_a")
self.out_b = tf.placeholder(tf.int32, [None, ], name="out_b")
self.out_c = tf.placeholder(tf.int32, [None, ], name="out_c")
self.out_d = tf.placeholder(tf.int32, [None, ], name="out_d")
self.discounted_episode_rewards_norm = tf.placeholder(tf.float32, [None, ],
name="discounted_episode_rewards_")
self.avg_reward_ = tf.placeholder(tf.float32, name="avg_reward")
print(self.discounted_episode_rewards_norm)
# Add this placeholder for having this variable in tensorboard
self.mean_reward_ = tf.placeholder(tf.float32, name="mean_reward")
#model=k.Sequential()
#inp = Input(shape=self.state_size, name='stack_of_4_images')(self.inputs)
c1 = Conv2D(32,8,strides=2,activation='relu',name='Conv1')(self.inputs) #kernel_initializer=glorot_uniform(seed=42),
c2 = Conv2D(64, (6,8), strides=2, activation='relu', name='Conv2')(c1) # kernel_initializer=glorot_uniform(seed=42),
c3 = Conv2D(128, (6,8), strides=2, activation='relu', name='Conv3')(c2) # kernel_initializer=glorot_uniform(seed=42),
flat = Flatten()(c3)
d1 = Dense(1024, activation='selu', name='Dense1')(flat)
d2 = Dense(1024, activation='selu', name='Dense2')(d1)
logits_a = Dense(self.output_size, name='logits_a')(d2)
logits_b = Dense(self.output_size, name='logits_b')(d2)
logits_c = Dense(self.output_size, name='logits_c')(d2)
logits_d = Dense(self.output_size, name='logits_d')(d2)
The error i get when i run my script that instantiates the model
File "/home/ubuntu/morph_basic/basic_bline.py", line 78, in build_model [logits_a.op, logits_b.op, logits_c.op, logits_d.op], threshold=1e-3) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/network_regularizers/flop_regularizer.py", line 153, in __init__ regularizer_blacklist=regularizer_blacklist) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_regularizer_manager.py", line 126, in __init__ self._op_handler_dict[op.type].assign_grouping(op, self) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/grouping_op_handler.py", line 40, in assign_grouping output_ops, op_reg_manager) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_handler_util.py", line 73, in get_ops_without_groups op_slices = op_reg_manager.get_op_slices(op) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/morph_net/framework/op_regularizer_manager.py", line 438, in get_op_slices if size > 0: TypeError: '>' not supported between instances of 'NoneType' and 'int'
The text was updated successfully, but these errors were encountered: