import tensorflow as tf

            if v.op.name in self.pretrained_weights.keys():
                assign_op = v.assign(self.pretrained_weights[v.op.name])
                sess.run(assign_op)
                print(v.op.name + " - loaded successfully")
        print("All pretrained weights of resnet18 is loaded")

    def _residual_block(self, name, x, filters, pool_first=False, strides=1, dilation=1):
        print('Building residual unit: %s' % name)
        with tf.variable_scope(name):
            # get input channels
            in_channel = x.shape.as_list()[-1]

            # Shortcut connection
            shortcut = tf.identity(x)

            if pool_first:
                if in_channel == filters:
                    if strides == 1:
                        shortcut = tf.identity(x)
                    else:
                        shortcut= tf.pad(x, tf.constant([[0,0],[1,1],[1,1],[0,0]]), "CONSTANT")
                        shortcut = tf.nn.max_pool(shortcut, [1, strides, strides, 1], [1, strides, strides, 1], 'VALID')
                else:
                    shortcut = self._conv('shortcut_conv', x, padding='VALID',
                                          num_filters=filters, kernel_size=(1, 1), stride=(strides, strides),
                                          bias=self.bias)
