Beispiel #1
0
 def draw_conv_series(self, x, shape=None):
     x = np.array(x)
     for xx in x:
         VisUtil.show_img(VisUtil.trans_img(xx, shape), "Original")
         for i, (layer, ac) in enumerate(
                 zip(
                     self._layers,
                     self._get_acts(
                         np.array([xx.transpose(1, 2, 0)],
                                  dtype=np.float32)))):
             if len(ac.shape) == 4:
                 VisUtil.show_batch_img(
                     ac[0].transpose(2, 0, 1),
                     "Layer {} ({})".format(i + 1, layer.name))
             else:
                 ac = ac[0]
                 length = sqrt(np.prod(ac.shape))
                 if length < 10:
                     continue
                 (height,
                  width) = xx.shape[1:] if shape is None else shape[1:]
                 sqrt_shape = sqrt(height * width)
                 oh, ow = int(length * height / sqrt_shape), int(
                     length * width / sqrt_shape)
                 VisUtil.show_img(ac[:oh * ow].reshape(oh, ow),
                                  "Layer {} ({})".format(i + 1, layer.name))
Beispiel #2
0
 def draw_conv_weights(self):
     with self._sess.as_default():
         for i, (name, weight) in enumerate(zip(self.layer_names, self._tf_weights)):
             weight = weight.eval()
             if len(weight.shape) != 4:
                 continue
             for j, _w in enumerate(weight.transpose(2, 3, 0, 1)):
                 VisUtil.show_batch_img(_w, "{} {} filter {}".format(name, i + 1, j + 1))
Beispiel #3
0
 def draw_conv_weights(self):
     with self._sess.as_default():
         for i, (name, weight) in enumerate(zip(self.layer_names, self._tf_weights)):
             weight = weight.eval()
             if len(weight.shape) != 4:
                 continue
             for j, _w in enumerate(weight.transpose(2, 3, 0, 1)):
                 VisUtil.show_batch_img(_w, "{} {} filter {}".format(name, i + 1, j + 1))
Beispiel #4
0
 def draw_conv_series(self, x, shape=None):
     x = np.asarray(x)
     for xx in x:
         VisUtil.show_img(VisUtil.trans_img(xx, shape), "Original")
         for i, (layer, ac) in enumerate(zip(
                 self._layers, self._get_acts(np.array([xx.transpose(1, 2, 0)], dtype=np.float32)))):
             if len(ac.shape) == 4:
                 VisUtil.show_batch_img(ac[0].transpose(2, 0, 1), "Layer {} ({})".format(i + 1, layer.name))
             else:
                 ac = ac[0]
                 length = sqrt(np.prod(ac.shape))
                 if length < 10:
                     continue
                 (height, width) = xx.shape[1:] if shape is None else shape[1:]
                 sqrt_shape = sqrt(height * width)
                 oh, ow = int(length * height / sqrt_shape), int(length * width / sqrt_shape)
                 VisUtil.show_img(ac[:oh * ow].reshape(oh, ow), "Layer {} ({})".format(i + 1, layer.name))