In [1]:
import numpy as np, tensorflow as tf
from glob import glob
from analysis import plot_deep_features, plot, smooth_ranges_2d, text
from make_frames import make_frames

In [2]:
import os
import h5py
from pprint import pprint
from tqdm import tqdm
from IPython import display
import matplotlib.pyplot as plt
import matplotlib.patches as patches
%matplotlib inline

In [3]:
%%sh
cd data/
ls -l


total 2225616
drwxrwxr-x 2 ubuntu ubuntu      4096 Oct 10 08:40 archive
-rw-rw-r-- 1 ubuntu ubuntu 360325126 Oct 10 22:33 lambda_0.001.h5
-rw-rw-r-- 1 ubuntu ubuntu 360325126 Oct 10 22:33 lambda_0.01.h5
-rw-rw-r-- 1 ubuntu ubuntu 360325126 Oct 10 08:48 lambda_0.1.h5
-rw-rw-r-- 1 ubuntu ubuntu 270406726 Oct 10 22:32 lambda_0.h5
-rw-rw-r-- 1 ubuntu ubuntu 360325126 Oct 10 08:48 lambda_1.h5
-rw-rw-r-- 1 ubuntu ubuntu 360325126 Oct 10 08:48 lambda_3.h5
-rw-rw-r-- 1 ubuntu ubuntu 206948030 Oct 10 22:31 pre_train_lambda_0.01.h5

In [4]:
%%sh
cd figures/animation/
ls -l


total 53500
drwxrwxr-x 9 ubuntu ubuntu     4096 Oct 10 08:55 archive
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 10 08:56 lambda_0.001
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 11 08:07 lambda_0.01
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 11 08:07 lambda_0.1
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 11 08:07 lambda_1
drwxrwxr-x 2 ubuntu ubuntu    20480 Oct 10 09:38 lambda_3
-rw-rw-r-- 1 ubuntu ubuntu 13046511 Oct 10 09:39 MNIST_LeNet_centroid_lambda_3.mp4
-rw-r--r-- 1 ubuntu ubuntu   461311 Oct  8 18:02 MNIST_LeNet_centroid_loss_01_faster.mp4
-rw-rw-r-- 1 ubuntu ubuntu  3176114 Oct  9 08:29 MNIST_LeNet_centroid_weak_test.mp4
-rw-rw-r-- 1 ubuntu ubuntu 25460482 Oct  9 21:17 MNIST_LeNet_long_centroid_test.mp4
-rw-rw-r-- 1 ubuntu ubuntu 12583274 Oct 11 04:11 MNIST_LeNet_pre_train_lambda_0.01.mp4
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 11 08:26 pre_train_lambda_0.01

In [5]:
configs = [
    
    {
        'path': 'data/pre_train_lambda_0.01.h5',
        'prefix': 'pre_train_lambda_0.01/frame'
    },
    {
        'path': 'data/lambda_3.h5',
        'prefix': 'lambda_3/frame'
    },
    {
        'path': 'data/lambda_1.h5',
        'prefix': 'lambda_1/frame'
    },
    {
        'path': 'data/lambda_0.1.h5',
        'prefix': 'lambda_0.1/frame'
    },
    {
        'path': 'data/lambda_0.01.h5',
        'prefix': 'lambda_0.01/frame'
    },
    {
        'path': 'data/lambda_0.001.h5',
        'prefix': 'lambda_0.001/frame'
    }
]

In [6]:
def make_movie(config):
    filepath = config['path']
    frame_prefix = config['prefix']
    make_frames(filepath, frame_prefix, title="MNIST LeNet++ Centroid Loss")

In [ ]:
from multiprocessing import Pool
with Pool(4) as p:
    p.map(make_movie, configs)


  2%|▏         | 12/561 [00:54<41:53,  4.58s/it]
  4%|▎         | 12/321 [00:55<22:02,  4.28s/it]

In [9]:
%%sh
# sudo shutdown -h now


shutdown: Need to be root

In [5]:
%%sh
cd figures/animation/pre_train_lambda_0.01
rm ../MNIST_LeNet_pre_train_lambda_0.01.mp4
ffmpeg -framerate 10 -i frame_%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ../MNIST_LeNet_pre_train_lambda_0.01.mp4


ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'frame_%03d.png':
  Duration: 00:00:32.10, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1650x1398 [SAR 11811:11811 DAR 275:233], 10 fps, 10 tbr, 10 tbn, 10 tbc
[libx264 @ 0x2424600] using SAR=1/1
[libx264 @ 0x2424600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x2424600] profile High, level 5.0
[libx264 @ 0x2424600] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x2421a00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to '../MNIST_LeNet_pre_train_lambda_0.01.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1650x1398 [SAR 1:1 DAR 275:233], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1650x1398 fmt:rgba to size:1685x1398 fmt:rgba
Input stream #0:0 frame changed from size:1685x1398 fmt:rgba to size:1652x1398 fmt:rgba
Input stream #0:0 frame changed from size:1652x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
Input stream #0:0 frame changed from size:1645x1398 fmt:rgba to size:1671x1398 fmt:rgba
Input stream #0:0 frame changed from size:1671x1398 fmt:rgba to size:1645x1398 fmt:rgba
frame=  962 fps= 52 q=-1.0 Lsize=   12515kB time=00:00:31.96 bitrate=3207.2kbits/s dup=641 drop=0 speed=1.73x    
video:12503kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.095218%
[libx264 @ 0x2424600] frame I:4     Avg QP:18.73  size:114968
[libx264 @ 0x2424600] frame P:598   Avg QP:20.16  size: 20447
[libx264 @ 0x2424600] frame B:360   Avg QP:15.58  size:   321
[libx264 @ 0x2424600] consecutive B-frames: 33.7% 49.1%  0.6% 16.6%
[libx264 @ 0x2424600] mb I  I16..4: 31.0% 42.1% 26.9%
[libx264 @ 0x2424600] mb P  I16..4:  0.4%  1.2%  1.7%  P16..4:  3.8%  2.6%  3.3%  0.0%  0.0%    skip:87.1%
[libx264 @ 0x2424600] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  2.6%  0.0%  0.0%  direct: 0.0%  skip:97.1%  L0:47.8% L1:52.1% BI: 0.2%
[libx264 @ 0x2424600] 8x8 transform intra:37.1% inter:12.3%
[libx264 @ 0x2424600] coded y,uvDC,uvAC intra: 36.8% 41.8% 38.7% inter: 2.2% 2.5% 2.0%
[libx264 @ 0x2424600] i16 v,h,dc,p: 71% 22%  8%  0%
[libx264 @ 0x2424600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22%  5% 69%  1%  1%  1%  1%  0%  1%
[libx264 @ 0x2424600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 16% 28%  5%  7%  6%  6%  6%  5%
[libx264 @ 0x2424600] i8c dc,h,v,p: 72% 12% 13%  3%
[libx264 @ 0x2424600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2424600] ref P L0: 54.7%  6.7% 14.3% 24.3%
[libx264 @ 0x2424600] ref B L0: 50.8% 42.3%  6.9%
[libx264 @ 0x2424600] ref B L1: 99.8%  0.2%
[libx264 @ 0x2424600] kb/s:3193.97

In [10]:
%%sh
cd figures/animation/lambda_3
ffmpeg -framerate 10 -i frame_%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ../MNIST_LeNet_lambda_3.mp4


ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'frame_%03d.png':
  Duration: 00:00:56.10, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1651x1398 [SAR 11811:11811 DAR 1651:1398], 10 fps, 10 tbr, 10 tbn, 10 tbc
[libx264 @ 0x37c3240] using SAR=1651/1650
[libx264 @ 0x37c3240] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x37c3240] profile High, level 5.0
[libx264 @ 0x37c3240] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x37c2080] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to '../MNIST_LeNet_lambda_3.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1650x1398 [SAR 1651:1650 DAR 1651:1398], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1651x1398 fmt:rgba to size:1684x1398 fmt:rgba
Input stream #0:0 frame changed from size:1684x1398 fmt:rgba to size:1651x1398 fmt:rgba
Input stream #0:0 frame changed from size:1651x1398 fmt:rgba to size:1685x1398 fmt:rgba
Input stream #0:0 frame changed from size:1685x1398 fmt:rgba to size:1651x1398 fmt:rgba
Input stream #0:0 frame changed from size:1651x1398 fmt:rgba to size:1684x1398 fmt:rgba
Input stream #0:0 frame changed from size:1684x1398 fmt:rgba to size:1651x1398 fmt:rgba
Input stream #0:0 frame changed from size:1651x1398 fmt:rgba to size:1625x1398 fmt:rgba
Input stream #0:0 frame changed from size:1625x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1625x1398 fmt:rgba
Input stream #0:0 frame changed from size:1625x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1659x1398 fmt:rgba
Input stream #0:0 frame changed from size:1659x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1625x1398 fmt:rgba
Input stream #0:0 frame changed from size:1625x1398 fmt:rgba to size:1659x1398 fmt:rgba
Input stream #0:0 frame changed from size:1659x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1659x1398 fmt:rgba
Input stream #0:0 frame changed from size:1659x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
frame= 1682 fps= 60 q=-1.0 Lsize=   12924kB time=00:00:55.96 bitrate=1891.7kbits/s dup=1121 drop=0 speed=   2x    
video:12904kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.154802%
[libx264 @ 0x37c3240] frame I:7     Avg QP:17.56  size: 73317
[libx264 @ 0x37c3240] frame P:993   Avg QP:21.10  size: 12522
[libx264 @ 0x37c3240] frame B:682   Avg QP:15.11  size:   388
[libx264 @ 0x37c3240] consecutive B-frames: 32.0% 41.5%  0.5% 25.9%
[libx264 @ 0x37c3240] mb I  I16..4: 33.7% 47.9% 18.4%
[libx264 @ 0x37c3240] mb P  I16..4:  0.4%  1.5%  1.5%  P16..4:  3.5%  1.9%  1.6%  0.0%  0.0%    skip:89.6%
[libx264 @ 0x37c3240] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  3.5%  0.1%  0.0%  direct: 0.0%  skip:96.2%  L0:49.2% L1:50.4% BI: 0.4%
[libx264 @ 0x37c3240] 8x8 transform intra:43.9% inter:17.9%
[libx264 @ 0x37c3240] coded y,uvDC,uvAC intra: 26.1% 30.4% 28.2% inter: 1.2% 1.3% 1.0%
[libx264 @ 0x37c3240] i16 v,h,dc,p: 74% 21%  5%  0%
[libx264 @ 0x37c3240] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23%  6% 69%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x37c3240] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 16% 31%  4%  5%  5%  5%  4%  4%
[libx264 @ 0x37c3240] i8c dc,h,v,p: 76% 11% 11%  2%
[libx264 @ 0x37c3240] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x37c3240] ref P L0: 57.5%  4.6% 14.5% 23.3%
[libx264 @ 0x37c3240] ref B L0: 62.2% 31.6%  6.2%
[libx264 @ 0x37c3240] ref B L1: 99.5%  0.5%
[libx264 @ 0x37c3240] kb/s:1885.32

In [11]:
%%sh
cd figures/animation/lambda_0.1
ffmpeg -framerate 10 -i frame_%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ../MNIST_LeNet_lambda_0.1.mp4


ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'frame_%03d.png':
  Duration: 00:00:56.10, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1650x1398 [SAR 11811:11811 DAR 275:233], 10 fps, 10 tbr, 10 tbn, 10 tbc
[libx264 @ 0x28c95c0] using SAR=1/1
[libx264 @ 0x28c95c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x28c95c0] profile High, level 5.0
[libx264 @ 0x28c95c0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x28c8400] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to '../MNIST_LeNet_lambda_0.1.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1650x1398 [SAR 1:1 DAR 275:233], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1650x1398 fmt:rgba to size:1685x1398 fmt:rgba
Input stream #0:0 frame changed from size:1685x1398 fmt:rgba to size:1625x1398 fmt:rgba
Input stream #0:0 frame changed from size:1625x1398 fmt:rgba to size:1659x1398 fmt:rgba
Input stream #0:0 frame changed from size:1659x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
Input stream #0:0 frame changed from size:1645x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
Input stream #0:0 frame changed from size:1645x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
Input stream #0:0 frame changed from size:1645x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
Input stream #0:0 frame changed from size:1645x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
frame= 1682 fps= 59 q=-1.0 Lsize=   16460kB time=00:00:55.96 bitrate=2409.4kbits/s dup=1121 drop=0 speed=1.98x    
video:16440kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.122763%
[libx264 @ 0x28c95c0] frame I:7     Avg QP:17.91  size: 90772
[libx264 @ 0x28c95c0] frame P:1054  Avg QP:20.61  size: 15158
[libx264 @ 0x28c95c0] frame B:621   Avg QP:14.82  size:   357
[libx264 @ 0x28c95c0] consecutive B-frames: 33.9% 50.7%  0.0% 15.5%
[libx264 @ 0x28c95c0] mb I  I16..4: 34.1% 43.9% 22.0%
[libx264 @ 0x28c95c0] mb P  I16..4:  0.4%  1.4%  1.5%  P16..4:  3.9%  2.3%  2.2%  0.0%  0.0%    skip:88.2%
[libx264 @ 0x28c95c0] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  3.0%  0.0%  0.0%  direct: 0.0%  skip:96.7%  L0:47.3% L1:52.5% BI: 0.2%
[libx264 @ 0x28c95c0] 8x8 transform intra:41.8% inter:15.3%
[libx264 @ 0x28c95c0] coded y,uvDC,uvAC intra: 27.3% 34.8% 32.0% inter: 1.6% 1.9% 1.5%
[libx264 @ 0x28c95c0] i16 v,h,dc,p: 73% 20%  6%  0%
[libx264 @ 0x28c95c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21%  7% 71%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x28c95c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 16% 33%  4%  5%  5%  5%  4%  4%
[libx264 @ 0x28c95c0] i8c dc,h,v,p: 72% 13% 13%  2%
[libx264 @ 0x28c95c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x28c95c0] ref P L0: 56.2%  5.3% 12.8% 25.7%
[libx264 @ 0x28c95c0] ref B L0: 46.0% 46.2%  7.8%
[libx264 @ 0x28c95c0] ref B L1: 99.7%  0.3%
[libx264 @ 0x28c95c0] kb/s:2402.02

In [12]:
%%sh
cd figures/animation/lambda_0.01
ffmpeg -framerate 10 -i frame_%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ../MNIST_LeNet_lambda_0.01.mp4


ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'frame_%03d.png':
  Duration: 00:00:56.10, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1652x1398 [SAR 11811:11811 DAR 826:699], 10 fps, 10 tbr, 10 tbn, 10 tbc
[libx264 @ 0x24e65c0] using SAR=1/1
[libx264 @ 0x24e65c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x24e65c0] profile High, level 5.0
[libx264 @ 0x24e65c0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x24e5400] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to '../MNIST_LeNet_lambda_0.01.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1652x1398 [SAR 1:1 DAR 826:699], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1652x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1617x1398 fmt:rgba
Input stream #0:0 frame changed from size:1617x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1645x1398 fmt:rgba
frame= 1682 fps= 57 q=-1.0 Lsize=   14980kB time=00:00:55.96 bitrate=2192.6kbits/s dup=1121 drop=0 speed=1.91x    
video:14960kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.133575%
[libx264 @ 0x24e65c0] frame I:7     Avg QP:15.09  size: 87892
[libx264 @ 0x24e65c0] frame P:971   Avg QP:20.23  size: 14896
[libx264 @ 0x24e65c0] frame B:704   Avg QP:14.98  size:   339
[libx264 @ 0x24e65c0] consecutive B-frames: 31.2% 38.6%  0.9% 29.3%
[libx264 @ 0x24e65c0] mb I  I16..4: 50.6% 27.8% 21.6%
[libx264 @ 0x24e65c0] mb P  I16..4:  0.3%  1.2%  1.4%  P16..4:  3.8%  2.3%  2.3%  0.0%  0.0%    skip:88.7%
[libx264 @ 0x24e65c0] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  3.0%  0.1%  0.0%  direct: 0.0%  skip:96.7%  L0:48.9% L1:50.6% BI: 0.6%
[libx264 @ 0x24e65c0] 8x8 transform intra:38.1% inter:15.2%
[libx264 @ 0x24e65c0] coded y,uvDC,uvAC intra: 29.4% 35.6% 32.3% inter: 1.5% 1.7% 1.3%
[libx264 @ 0x24e65c0] i16 v,h,dc,p: 75% 19%  6%  0%
[libx264 @ 0x24e65c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19%  6% 72%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x24e65c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 16% 32%  4%  6%  5%  5%  5%  4%
[libx264 @ 0x24e65c0] i8c dc,h,v,p: 72% 13% 13%  2%
[libx264 @ 0x24e65c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x24e65c0] ref P L0: 57.0%  5.5% 15.3% 22.2%
[libx264 @ 0x24e65c0] ref B L0: 63.3% 29.6%  7.1%
[libx264 @ 0x24e65c0] ref B L1: 99.6%  0.4%
[libx264 @ 0x24e65c0] kb/s:2185.69

In [13]:
%%sh
cd figures/animation/lambda_0.001
ffmpeg -framerate 10 -i frame_%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ../MNIST_LeNet_lambda_0.001.mp4


ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'frame_%03d.png':
  Duration: 00:00:56.10, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 1650x1398 [SAR 11811:11811 DAR 275:233], 10 fps, 10 tbr, 10 tbn, 10 tbc
[libx264 @ 0x358f980] using SAR=1/1
[libx264 @ 0x358f980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x358f980] profile High, level 5.0
[libx264 @ 0x358f980] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x358e7c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to '../MNIST_LeNet_lambda_0.001.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1650x1398 [SAR 1:1 DAR 275:233], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1650x1398 fmt:rgba to size:1685x1398 fmt:rgba
Input stream #0:0 frame changed from size:1685x1398 fmt:rgba to size:1657x1398 fmt:rgba
Input stream #0:0 frame changed from size:1657x1398 fmt:rgba to size:1658x1398 fmt:rgba
Input stream #0:0 frame changed from size:1658x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1619x1398 fmt:rgba
Input stream #0:0 frame changed from size:1619x1398 fmt:rgba to size:1618x1398 fmt:rgba
Input stream #0:0 frame changed from size:1618x1398 fmt:rgba to size:1645x1398 fmt:rgba
frame= 1682 fps= 55 q=-1.0 Lsize=   17245kB time=00:00:55.96 bitrate=2524.1kbits/s dup=1121 drop=0 speed=1.83x    
video:17225kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.116698%
[libx264 @ 0x358f980] frame I:7     Avg QP:17.81  size:106229
[libx264 @ 0x358f980] frame P:967   Avg QP:20.08  size: 17186
[libx264 @ 0x358f980] frame B:708   Avg QP:15.22  size:   389
[libx264 @ 0x358f980] consecutive B-frames: 30.5% 40.1%  0.2% 29.3%
[libx264 @ 0x358f980] mb I  I16..4: 29.5% 45.1% 25.4%
[libx264 @ 0x358f980] mb P  I16..4:  0.4%  1.3%  1.5%  P16..4:  4.1%  2.7%  2.9%  0.0%  0.0%    skip:87.2%
[libx264 @ 0x358f980] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  3.7%  0.1%  0.0%  direct: 0.0%  skip:96.0%  L0:49.7% L1:49.4% BI: 1.0%
[libx264 @ 0x358f980] 8x8 transform intra:40.9% inter:15.4%
[libx264 @ 0x358f980] coded y,uvDC,uvAC intra: 30.8% 36.1% 32.8% inter: 1.9% 2.1% 1.6%
[libx264 @ 0x358f980] i16 v,h,dc,p: 71% 22%  7%  0%
[libx264 @ 0x358f980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23%  6% 68%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x358f980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 16% 31%  4%  6%  6%  5%  5%  4%
[libx264 @ 0x358f980] i8c dc,h,v,p: 72% 13% 13%  2%
[libx264 @ 0x358f980] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x358f980] ref P L0: 56.2%  5.8% 14.9% 23.1%
[libx264 @ 0x358f980] ref B L0: 64.2% 29.5%  6.3%
[libx264 @ 0x358f980] ref B L1: 99.5%  0.5%
[libx264 @ 0x358f980] kb/s:2516.60