#pragma HLS PIPELINE II=1
ERROR: [XFORM 203-504] Stop unrolling loop 'af1_dot1' (all_deploy_afnet4mnist2/mnist_nn.cpp:840) in function 'mnist_nn' because it may cause large runtime and excessive memory usage due to increase in code size. Please avoid unrolling the loop or form sub-functions for code in the loop body.
ERROR: [HLS 200-70] Pre-synthesis failed.
open_project all_deploy_afnet4mnist3
set_top mnist_nn
add_files mnist_nn.cpp
open_solution solution1
create_clock -period 10 -name default
config_compile -ignore_long_run_time
set_part {xczu3eg-sbva484-1-e}
csynth_design
masaaki@masaaki-H110M4-M01:~/Vivado_HLS/Ultra96/NN/all_deploy_afnet4mnist3$ vivado_hls ignore_long_run_time.tcl
****** Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit)
**** SW Build 2405991 on Thu Dec 6 23:36:41 MST 2018
**** IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
source /tools/Xilinx/Vivado/2018.3/scripts/vivado_hls/hls.tcl -notrace
INFO: [HLS 200-10] Running '/tools/Xilinx/Vivado/2018.3/bin/unwrapped/lnx64.o/vivado_hls'
INFO: [HLS 200-10] For user 'masaaki' on host 'masaaki-H110M4-M01' (Linux_x86_64 version 4.15.0-46-generic) on Sat Mar 30 12:31:54 JST 2019
INFO: [HLS 200-10] On os Ubuntu 18.04.2 LTS
INFO: [HLS 200-10] In directory '/home/masaaki/Vivado_HLS/Ultra96/NN/all_deploy_afnet4mnist3'
WARNING: [HLS 200-40] Environment variable 'C_INCLUDE_PATH' is set to :/usr/local/cuda/include.
INFO: [HLS 200-10] Opening project '/home/masaaki/Vivado_HLS/Ultra96/NN/all_deploy_afnet4mnist3/all_deploy_afnet4mnist3'.
INFO: [HLS 200-10] Adding design file 'mnist_nn.cpp' to the project
INFO: [HLS 200-10] Opening solution '/home/masaaki/Vivado_HLS/Ultra96/NN/all_deploy_afnet4mnist3/all_deploy_afnet4mnist3/solution1'.
INFO: [SYN 201-201] Setting up clock 'default' with a period of 10ns.
INFO: [HLS 200-10] Setting target device to 'xczu3eg-sbva484-1-e'
WARNING: [ANALYSIS 214-1] Skip long-run-time warning caused by lots of load/store instructions.
WARNING: [ANALYSIS 214-1] Skip long-run-time warning caused by lots of load/store instructions.
INFO: [SCHED 204-61] Option 'relax_ii_for_timing' is enabled, will increase II to preserve clock frequency constraints.
INFO: [HLS 200-10] Analyzing design file 'mnist_nn.cpp' ...
INFO: [HLS 200-111] Finished Linking Time (s): cpu = 00:00:19 ; elapsed = 00:00:20 . Memory (MB): peak = 452.242 ; gain = 13.375 ; free physical = 25266 ; free virtual = 43474
INFO: [HLS 200-111] Finished Checking Pragmas Time (s): cpu = 00:00:19 ; elapsed = 00:00:20 . Memory (MB): peak = 452.242 ; gain = 13.375 ; free physical = 25266 ; free virtual = 43474
INFO: [HLS 200-10] Starting code transformations ...
INFO: [HLS 200-111] Finished Standard Transforms Time (s): cpu = 00:00:27 ; elapsed = 00:00:28 . Memory (MB): peak = 581.059 ; gain = 142.191 ; free physical = 25221 ; free virtual = 43429
INFO: [HLS 200-10] Checking synthesizability ...
INFO: [HLS 200-111] Finished Checking Synthesizability Time (s): cpu = 00:00:27 ; elapsed = 00:00:28 . Memory (MB): peak = 581.059 ; gain = 142.191 ; free physical = 25221 ; free virtual = 43429
INFO: [XFORM 203-502] Unrolling all sub-loops inside loop 'num_of_iter' (mnist_nn.cpp:839) in function 'mnist_nn' for pipelining.
INFO: [HLS 200-489] Unrolling loop 'af1_dot1' (mnist_nn.cpp:841) in function 'mnist_nn' completely with a factor of 20.
ERROR: [XFORM 203-504] Stop unrolling loop 'af1_dot1' (mnist_nn.cpp:841) in function 'mnist_nn' because it may cause large runtime and excessive memory usage due to increase in code size. Please avoid unrolling the loop or form sub-functions for code in the loop body.
ERROR: [HLS 200-70] Pre-synthesis failed.
command 'ap_source' returned error code
while executing
"source ignore_long_run_time.tcl"
invoked from within
"hls::main ignore_long_run_time.tcl"
("uplevel" body line 1)
invoked from within
"uplevel 1 hls::main {*}$args"
(procedure "hls_proc" line 5)
invoked from within
"hls_proc $argv"
INFO: [Common 17-206] Exiting vivado_hls at Sat Mar 30 12:32:22 2019...
int mnist_nn(ap_ufixed<8, 0, AP_TRN, AP_WRAP> in[784], ap_fixed<13, 7, AP_TRN, AP_WRAP> out[10]){
#pragma HLS DATAFLOW
#pragma HLS ARRAY_PARTITION variable=af2_bias complete dim=0
#pragma HLS ARRAY_PARTITION variable=af2_weight complete dim=0
#pragma HLS ARRAY_PARTITION variable=af1_bias complete dim=0
#pragma HLS ARRAY_PARTITION variable=af1_weight complete dim=0
#pragma HLS ARRAY_PARTITION variable=out complete dim=0
#pragma HLS ARRAY_PARTITION variable=in complete dim=0
ap_fixed<13, 7, AP_TRN, AP_WRAP> dot1[50];
#pragma HLS ARRAY_PARTITION variable=dot1 complete dim=1
ap_fixed<13, 7, AP_TRN, AP_WRAP> dot2[10];
#pragma HLS ARRAY_PARTITION variable=dot2 complete dim=1
af1_dot1: for(int col=0; col<20; col++){
#pragma HLS PIPELINE II=1
dot1[col] = 0;
af1_dot2: for(int row=0; row<784; row++){
dot1[col] += in[row]*af1_weight[row][col];
}
dot1[col] += af1_bias[col];
if(dot1[col] < 0) // ReLU
dot1[col] = 0;
}
af2_dot1: for(int col=0; col<10; col++){
#pragma HLS PIPELINE II=1
dot2[col] = 0;
af2_dot2: for(int row=0; row<20; row++){
dot2[col] += dot1[row]*af2_weight[row][col];
}
dot2[col] += af2_bias[col];
if(dot2[col] < 0) // ReLU
dot2[col] = 0;
out[col] = dot2[col];
}
return(0);
}
// mnist_nn_tb.cpp
// 2017/06/02 by marsee
//
#include <stdio.h>
#include <ap_fixed.h>
#include "af1_weight.h"
#include "af1_bias.h"
#include "af2_weight.h"
#include "af2_bias.h"
#include "mnist_data.h"
int mnist_nn(ap_ufixed<8, 0, AP_TRN, AP_WRAP> in[784], ap_fixed<13, 7, AP_TRN, AP_WRAP> out[10]);
int mnist_nn_float(float in[784], float out[10]);
int max_ap_fixed(ap_fixed<13, 7, AP_TRN, AP_WRAP> out[10]);
int max_float(float out[10]);
#define NUM_ITERATIONS 100 // C Simulation
// #define NUM_ITERATIONS 2 // C/RTL CoSimulation
int main(){
float x_test_float[NUM_ITERATIONS][784];
ap_fixed<13, 7, AP_TRN, AP_WRAP> result_ap_fixed[NUM_ITERATIONS][10];
float result_float[NUM_ITERATIONS][10];
int max_id_hw, max_id_sw, max_id_ref;
for(int i=0; i<NUM_ITERATIONS; i++)
for(int j=0; j<784; j++)
x_test_float[i][j] = (float)x_test[i][j];
for(int i=0; i<NUM_ITERATIONS; i++){
mnist_nn(&x_test[i][0], &result_ap_fixed[i][0]);
mnist_nn_float(&x_test_float[i][0], &result_float[i][0]);
}
int errflag=0;
for(int i=0; i<NUM_ITERATIONS; i++){
max_id_hw = max_ap_fixed(&result_ap_fixed[i][0]);
max_id_sw = max_float(&result_float[i][0]);
max_id_ref = y_test[i];
if(max_id_ref != max_id_hw){
printf("id = %d, max_id_ref = %d, max_id_hw = %d\n", i, max_id_ref, max_id_hw);
errflag = 1;
}
if(max_id_ref != max_id_sw){
printf("id = %d, max_id_ref = %d, max_id_sw = %d\n", i, max_id_ref, max_id_sw);
errflag = 1;
}
}
if(errflag == 0)
printf("No Error\n");
return(0);
}
int mnist_nn_float(float in[784], float out[10]){
float dot1[50];
float dot2[10];
af1_dot1: for(int col=0; col<20; col++){
dot1[col] = 0;
af1_dot2: for(int row=0; row<784; row++){
dot1[col] += in[row]*af1_fweight[row][col];
}
dot1[col] += af1_fbias[col];
if(dot1[col] < 0) // ReLU
dot1[col] = 0;
}
af2_dot1: for(int col=0; col<10; col++){
dot2[col] = 0;
af2_dot2: for(int row=0; row<20; row++){
dot2[col] += dot1[row]*af2_fweight[row][col];
}
dot2[col] += af2_fbias[col];
if(dot2[col] < 0) // ReLU
dot2[col] = 0;
out[col] = dot2[col];
}
return(0);
}
int max_ap_fixed(ap_fixed<13, 7, AP_TRN, AP_WRAP> out[10]){
int max_id;
ap_fixed<13, 5, AP_TRN, AP_WRAP> max;
for(int i=0; i<10; i++){
if(i == 0){
max = out[0];
max_id = 0;
}else if(out[i]>max){
max = out[i];
max_id = i;
}
}
return(max_id);
}
int max_float(float out[10]){
int max_id;
float max;
for(int i=0; i<10; i++){
if(i == 0){
max = out[0];
max_id = 0;
}else if(out[i]>max){
max = out[i];
max_id = i;
}
}
return(max_id);
}
# Mnist NN
# Dence - ReLU - Dence
# 2019/03/21 by marsee
# Keras / Tensorflowで始めるディープラーニング入門 https://qiita.com/yampy/items/706d44417c433e68db0d
# のPythonコードを再利用させて頂いている
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Activation
from keras import backend as K
batch_size = 128
num_classes = 10
epochs = 20
img_rows, img_cols = 28, 28
(x_train, y_train), (x_test, y_test) = mnist.load_data()
#Kerasのバックエンドで動くTensorFlowとTheanoでは入力チャンネルの順番が違うので場合分けして書いています
if K.image_data_format() == 'channels_first':
x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
input_shape = (1, img_rows, img_cols)
else:
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1)
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')
y_train = y_train.astype('int32')
y_test = y_test.astype('int32')
y_train = keras.utils.np_utils.to_categorical(y_train, num_classes)
y_test = keras.utils.np_utils.to_categorical(y_test, num_classes)
model = Sequential()
model.add(Flatten(input_shape=input_shape))
model.add(Dense(20,))
model.add(Activation(activation='relu'))
model.add(Dense(num_classes))
model.add(Activation(activation='softmax'))
model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs,
verbose=1, validation_data=(x_test, y_test))
x_train shape: (60000, 28, 28, 1)
60000 train samples
10000 test samples
Train on 60000 samples, validate on 10000 samples
Epoch 1/20
60000/60000 [==============================] - 1s 12us/step - loss: 0.4821 - acc: 0.8667 - val_loss: 0.2877 - val_acc: 0.9170
Epoch 2/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.2741 - acc: 0.9219 - val_loss: 0.2528 - val_acc: 0.9259
Epoch 3/20
60000/60000 [==============================] - 1s 12us/step - loss: 0.2440 - acc: 0.9307 - val_loss: 0.2278 - val_acc: 0.9331
Epoch 4/20
60000/60000 [==============================] - 1s 10us/step - loss: 0.2240 - acc: 0.9363 - val_loss: 0.2129 - val_acc: 0.9380
Epoch 5/20
60000/60000 [==============================] - 1s 12us/step - loss: 0.2082 - acc: 0.9405 - val_loss: 0.2069 - val_acc: 0.9391
Epoch 6/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1949 - acc: 0.9446 - val_loss: 0.1954 - val_acc: 0.9436
Epoch 7/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1845 - acc: 0.9472 - val_loss: 0.1850 - val_acc: 0.9443
Epoch 8/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1754 - acc: 0.9502 - val_loss: 0.1787 - val_acc: 0.9449
Epoch 9/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1675 - acc: 0.9523 - val_loss: 0.1692 - val_acc: 0.9489
Epoch 10/20
60000/60000 [==============================] - 1s 10us/step - loss: 0.1611 - acc: 0.9537 - val_loss: 0.1653 - val_acc: 0.9506
Epoch 11/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1551 - acc: 0.9557 - val_loss: 0.1641 - val_acc: 0.9508
Epoch 12/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1499 - acc: 0.9570 - val_loss: 0.1565 - val_acc: 0.9525
Epoch 13/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1447 - acc: 0.9580 - val_loss: 0.1548 - val_acc: 0.9547
Epoch 14/20
60000/60000 [==============================] - 1s 12us/step - loss: 0.1404 - acc: 0.9598 - val_loss: 0.1523 - val_acc: 0.9556
Epoch 15/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1366 - acc: 0.9604 - val_loss: 0.1507 - val_acc: 0.9567
Epoch 16/20
60000/60000 [==============================] - 1s 10us/step - loss: 0.1333 - acc: 0.9612 - val_loss: 0.1464 - val_acc: 0.9580
Epoch 17/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1301 - acc: 0.9622 - val_loss: 0.1483 - val_acc: 0.9574
Epoch 18/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1273 - acc: 0.9629 - val_loss: 0.1488 - val_acc: 0.9561
Epoch 19/20
60000/60000 [==============================] - 1s 10us/step - loss: 0.1240 - acc: 0.9639 - val_loss: 0.1463 - val_acc: 0.9587
Epoch 20/20
60000/60000 [==============================] - 1s 11us/step - loss: 0.1219 - acc: 0.9647 - val_loss: 0.1456 - val_acc: 0.9582
np.max(dense_layer1_weight) = 0.7293087244033813
np.min(dense_layer1_weight) = -0.7584445476531982
np.max(abs_dense_layer1_weight) = 0.7584445476531982
np.min(abs_dense_layer1_weight) = 4.789723334397422e-06
np.max(dense_layer1_bias) = 0.6915823221206665
np.min(dense_layer1_bias) = -0.4776344299316406
np.max(abs_dense_layer1_bias) = 0.6915823221206665
np.min(abs_dense_layer1_bias) = 0.003908126149326563
dense_layer1_output = (10000, 20)
np.std(dense_layer1_output) = 3.5381150245666504
np.max(dense_layer1_output) = 20.608829498291016
np.min(dense_layer1_output) = -19.995159149169922
np.max(abs_dense_layer1_output) = 20.608829498291016
np.min(abs_dense_layer1_output) = 5.525350570678711e-05
np.max(dense_layer2_weight) = 1.0690280199050903
np.min(dense_layer2_weight) = -1.5573456287384033
np.max(abs_dense_layer2_weight) = 1.5573456287384033
np.min(abs_dense_layer2_weight) = 0.0014803161611780524
np.max(dense_layer2_bias) = 0.4283429980278015
np.min(dense_layer2_bias) = -0.5694308876991272
np.max(abs_dense_layer2_bias) = 0.5694308876991272
np.min(abs_dense_layer2_bias) = 0.01991107501089573
dense_layer2_output = (10000, 10)
np.std(dense_layer2_output) = 7.384382724761963
np.max(dense_layer2_output) = 26.466449737548828
np.min(dense_layer2_output) = -48.657554626464844
np.max(abs_dense_layer2_output) = 48.657554626464844
np.min(abs_dense_layer2_output) = 3.4905970096588135e-06
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ ./sample-mnist All
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {28, 28, 1} output shape : {1024}
------------------------------------------------------------------
[BatchNormalization]
input shape : {1024} output shape : {1024}
------------------------------------------------------------------
[ReLU]
input shape : {1024} output shape : {1024}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {1024} output shape : {480}
------------------------------------------------------------------
[BatchNormalization]
input shape : {480} output shape : {480}
------------------------------------------------------------------
[ReLU]
input shape : {480} output shape : {480}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {480} output shape : {80}
------------------------------------------------------------------
[BatchNormalization]
input shape : {80} output shape : {80}
------------------------------------------------------------------
[ReLU]
input shape : {80} output shape : {80}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {80} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutMlp
17.75s epoch[ 1] test_accuracy : 0.8025 train_accuracy : 0.8013
37.07s epoch[ 2] test_accuracy : 0.8581 train_accuracy : 0.8490
56.73s epoch[ 3] test_accuracy : 0.8395 train_accuracy : 0.8336
83.60s epoch[ 4] test_accuracy : 0.8591 train_accuracy : 0.8549
105.18s epoch[ 5] test_accuracy : 0.8502 train_accuracy : 0.8488
128.99s epoch[ 6] test_accuracy : 0.8568 train_accuracy : 0.8498
155.94s epoch[ 7] test_accuracy : 0.8700 train_accuracy : 0.8693
180.72s epoch[ 8] test_accuracy : 0.8595 train_accuracy : 0.8526
fitting end
lut_accuracy : 0.8595
export : verilog/MnistSimpleLutMlp.v
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[LoweringConvolution]
input shape : {28, 28, 1} output shape : {26, 26, 32}
--------------------------------------------------------------------
[LoweringConvolution]
input shape : {26, 26, 32} output shape : {24, 24, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {24, 24, 32} output shape : {12, 12, 32}
--------------------------------------------------------------------
[LoweringConvolution]
input shape : {12, 12, 32} output shape : {10, 10, 32}
--------------------------------------------------------------------
[LoweringConvolution]
input shape : {10, 10, 32} output shape : {8, 8, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {8, 8, 32} output shape : {4, 4, 32}
--------------------------------------------------------------------
[MicroMlp]
input shape : {4, 4, 32} output shape : {480}
--------------------------------------------------------------------
[MicroMlp]
input shape : {480} output shape : {80}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {80} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutCnn
101.68s epoch[ 1] test_accuracy : 0.7680 train_accuracy : 0.7581
248.48s epoch[ 2] test_accuracy : 0.8577 train_accuracy : 0.8424
437.53s epoch[ 3] test_accuracy : 0.8624 train_accuracy : 0.8540
610.11s epoch[ 4] test_accuracy : 0.9123 train_accuracy : 0.9042
825.40s epoch[ 5] test_accuracy : 0.9187 train_accuracy : 0.9075
967.89s epoch[ 6] test_accuracy : 0.9176 train_accuracy : 0.9052
1108.22s epoch[ 7] test_accuracy : 0.9179 train_accuracy : 0.9111
1259.69s epoch[ 8] test_accuracy : 0.9258 train_accuracy : 0.9240
fitting end
export : verilog/MnistSimpleLutCnn.v
fitting start : MnistDenseAffine
[initial] test_accuracy : 0.1566 train_accuracy : 0.1472
69.02s epoch[ 1] test_accuracy : 0.8887 train_accuracy : 0.8892
145.43s epoch[ 2] test_accuracy : 0.9135 train_accuracy : 0.9251
220.56s epoch[ 3] test_accuracy : 0.9259 train_accuracy : 0.9395
294.60s epoch[ 4] test_accuracy : 0.9351 train_accuracy : 0.9562
367.37s epoch[ 5] test_accuracy : 0.9363 train_accuracy : 0.9615
445.29s epoch[ 6] test_accuracy : 0.9430 train_accuracy : 0.9699
523.36s epoch[ 7] test_accuracy : 0.9448 train_accuracy : 0.9727
594.80s epoch[ 8] test_accuracy : 0.9485 train_accuracy : 0.9789
fitting end
accuracy : 0.162803
accuracy : 0.185766
accuracy : 0.187984
accuracy : 0.18695
accuracy : 0.184648
accuracy : 0.185732
accuracy : 0.190301
accuracy : 0.189684
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ make WITH_CUDA=Yes all
make -C ../../cuda
make[1]: ディレクトリ '/home/masaaki/Docker/BinaryBrain/BinaryBrain/cuda' に入ります
nvcc -c -I ../include Manager.cu -o Manager.o
nvcc -c -I ../include MicroMlp.cu -o MicroMlp.o
nvcc -c -I ../include Im2Col.cu -o Im2Col.o
nvcc -c -I ../include Col2Im.cu -o Col2Im.o
nvcc -c -I ../include MaxPooling.cu -o MaxPooling.o
nvcc -c -I ../include BatchNormalization.cu -o BatchNormalization.o
nvcc -c -I ../include ReLU.cu -o ReLU.o
nvcc -c -I ../include Binarize.cu -o Binarize.o
nvcc -c -I ../include Vector.cu -o Vector.o
nvcc -c -I ../include HorizontalSum.cu -o HorizontalSum.o
ar rcs libbbcu.a Manager.o MicroMlp.o Im2Col.o Col2Im.o MaxPooling.o BatchNormalization.o ReLU.o Binarize.o Vector.o HorizontalSum.o
make[1]: ディレクトリ '/home/masaaki/Docker/BinaryBrain/BinaryBrain/cuda' から出ます
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c main.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleLutMlp.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleLutCnn.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistDenseAffine.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleMicroMlpScratch.cpp
nvcc -o sample-mnist -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA main.o MnistSimpleLutMlp.o MnistSimpleLutCnn.o MnistDenseAffine.o MnistSimpleMicroMlpScratch.o ../../cuda/libbbcu.a
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ make WITH_CUDA=Yes run
wget http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
--2019-03-21 22:55:05-- http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 9912422 (9.5M) [application/x-gzip]
`train-images-idx3-ubyte.gz' に保存中
train-images-idx3-u 100%[===================>] 9.45M 2.83MB/s 時間 3.3s
2019-03-21 22:55:09 (2.83 MB/s) - `train-images-idx3-ubyte.gz' へ保存完了 [9912422/9912422]
gzip -c -d train-images-idx3-ubyte.gz > train-images-idx3-ubyte
wget http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
--2019-03-21 22:55:09-- http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 28881 (28K) [application/x-gzip]
`train-labels-idx1-ubyte.gz' に保存中
train-labels-idx1-u 100%[===================>] 28.20K 161KB/s 時間 0.2s
2019-03-21 22:55:10 (161 KB/s) - `train-labels-idx1-ubyte.gz' へ保存完了 [28881/28881]
gzip -c -d train-labels-idx1-ubyte.gz > train-labels-idx1-ubyte
wget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
--2019-03-21 22:55:10-- http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 1648877 (1.6M) [application/x-gzip]
`t10k-images-idx3-ubyte.gz' に保存中
t10k-images-idx3-ub 100%[===================>] 1.57M 1.19MB/s 時間 1.3s
2019-03-21 22:55:11 (1.19 MB/s) - `t10k-images-idx3-ubyte.gz' へ保存完了 [1648877/1648877]
gzip -c -d t10k-images-idx3-ubyte.gz > t10k-images-idx3-ubyte
wget http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
--2019-03-21 22:55:12-- http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 4542 (4.4K) [application/x-gzip]
`t10k-labels-idx1-ubyte.gz' に保存中
t10k-labels-idx1-ub 100%[===================>] 4.44K --.-KB/s 時間 0s
2019-03-21 22:55:12 (196 MB/s) - `t10k-labels-idx1-ubyte.gz' へ保存完了 [4542/4542]
gzip -c -d t10k-labels-idx1-ubyte.gz > t10k-labels-idx1-ubyte
./sample-mnist All
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {28, 28, 1} output shape : {1024}
------------------------------------------------------------------
[BatchNormalization]
input shape : {1024} output shape : {1024}
------------------------------------------------------------------
[ReLU]
input shape : {1024} output shape : {1024}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {1024} output shape : {360}
------------------------------------------------------------------
[BatchNormalization]
input shape : {360} output shape : {360}
------------------------------------------------------------------
[ReLU]
input shape : {360} output shape : {360}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {360} output shape : {60}
------------------------------------------------------------------
[BatchNormalization]
input shape : {60} output shape : {60}
------------------------------------------------------------------
[ReLU]
input shape : {60} output shape : {60}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {60} output shape : {10}
------------------------------------------------------------------
[BatchNormalization]
input shape : {10} output shape : {10}
------------------------------------------------------------------
[ReLU]
input shape : {10} output shape : {10}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {10} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutMlp
13.36s epoch[ 1] test_accuracy : 0.7730 train_accuracy : 0.7721
29.92s epoch[ 2] test_accuracy : 0.8502 train_accuracy : 0.8425
46.17s epoch[ 3] test_accuracy : 0.8627 train_accuracy : 0.8567
62.37s epoch[ 4] test_accuracy : 0.8740 train_accuracy : 0.8649
78.69s epoch[ 5] test_accuracy : 0.8574 train_accuracy : 0.8561
95.02s epoch[ 6] test_accuracy : 0.8728 train_accuracy : 0.8687
111.27s epoch[ 7] test_accuracy : 0.8762 train_accuracy : 0.8670
127.36s epoch[ 8] test_accuracy : 0.8512 train_accuracy : 0.8435
fitting end
lut_accuracy : 0.8512
export : verilog/MnistSimpleLutMlp.v
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {28, 28, 1} output shape : {3, 3, 1}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 1} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {26, 26, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {26, 26, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {24, 24, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {24, 24, 32} output shape : {12, 12, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {12, 12, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {10, 10, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {10, 10, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {8, 8, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {8, 8, 32} output shape : {4, 4, 32}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {4, 4, 32} output shape : {480}
------------------------------------------------------------------
[BatchNormalization]
input shape : {480} output shape : {480}
------------------------------------------------------------------
[ReLU]
input shape : {480} output shape : {480}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {480} output shape : {80}
------------------------------------------------------------------
[BatchNormalization]
input shape : {80} output shape : {80}
------------------------------------------------------------------
[ReLU]
input shape : {80} output shape : {80}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {80} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutCnn
124.06s epoch[ 1] test_accuracy : 0.7005 train_accuracy : 0.6954
289.07s epoch[ 2] test_accuracy : 0.7654 train_accuracy : 0.7505
452.73s epoch[ 3] test_accuracy : 0.8321 train_accuracy : 0.8249
608.97s epoch[ 4] test_accuracy : 0.8677 train_accuracy : 0.8623
763.16s epoch[ 5] test_accuracy : 0.8865 train_accuracy : 0.8776
918.64s epoch[ 6] test_accuracy : 0.8932 train_accuracy : 0.8867
1072.93s epoch[ 7] test_accuracy : 0.9020 train_accuracy : 0.8948
1227.28s epoch[ 8] test_accuracy : 0.9118 train_accuracy : 0.9069
fitting end
fitting start : MnistDenseAffine
[initial] test_accuracy : 0.1566 train_accuracy : 0.1472
94.77s epoch[ 1] test_accuracy : 0.8678 train_accuracy : 0.8640
195.43s epoch[ 2] test_accuracy : 0.9004 train_accuracy : 0.9061
294.99s epoch[ 3] test_accuracy : 0.9139 train_accuracy : 0.9227
395.53s epoch[ 4] test_accuracy : 0.9248 train_accuracy : 0.9418
495.72s epoch[ 5] test_accuracy : 0.9264 train_accuracy : 0.9440
595.85s epoch[ 6] test_accuracy : 0.9356 train_accuracy : 0.9590
696.22s epoch[ 7] test_accuracy : 0.9369 train_accuracy : 0.9606
796.36s epoch[ 8] test_accuracy : 0.9419 train_accuracy : 0.9673
fitting end
accuracy : 0.153032
accuracy : 0.176794
accuracy : 0.207094
accuracy : 0.216566
accuracy : 0.2188
accuracy : 0.216499
accuracy : 0.219384
accuracy : 0.219834
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ make WITH_CUDA=Yes all
make -C ../../cuda
make[1]: ディレクトリ '/home/masaaki/Docker/BinaryBrain/BinaryBrain/cuda' に入ります
nvcc -c -I ../include Manager.cu -o Manager.o
nvcc -c -I ../include MicroMlp.cu -o MicroMlp.o
nvcc -c -I ../include Im2Col.cu -o Im2Col.o
nvcc -c -I ../include Col2Im.cu -o Col2Im.o
nvcc -c -I ../include MaxPooling.cu -o MaxPooling.o
nvcc -c -I ../include BatchNormalization.cu -o BatchNormalization.o
nvcc -c -I ../include ReLU.cu -o ReLU.o
nvcc -c -I ../include Binarize.cu -o Binarize.o
nvcc -c -I ../include Vector.cu -o Vector.o
nvcc -c -I ../include HorizontalSum.cu -o HorizontalSum.o
ar rcs libbbcu.a Manager.o MicroMlp.o Im2Col.o Col2Im.o MaxPooling.o BatchNormalization.o ReLU.o Binarize.o Vector.o HorizontalSum.o
make[1]: ディレクトリ '/home/masaaki/Docker/BinaryBrain/BinaryBrain/cuda' から出ます
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c main.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleLutMlp.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleLutCnn.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistDenseAffine.cpp
nvcc -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA -c MnistSimpleMicroMlpScratch.cpp
nvcc -o sample-mnist -Xcompiler '-O2 -mavx2 -mfma -fopenmp -std=c++14' -I../../include -I../../eigen -I../../cereal/include -DBB_WITH_CEREAL -DBB_WITH_CUDA main.o MnistSimpleLutMlp.o MnistSimpleLutCnn.o MnistDenseAffine.o MnistSimpleMicroMlpScratch.o ../../cuda/libbbcu.a
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
masaaki@masaaki-H110M4-M01:~/Docker/BinaryBrain/BinaryBrain/sample/mnist$ make WITH_CUDA=Yes run
wget http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
--2019-03-20 06:00:28-- http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 9912422 (9.5M) [application/x-gzip]
`train-images-idx3-ubyte.gz' に保存中
train-images-idx3-u 100%[===================>] 9.45M 1.75MB/s 時間 9.4s
2019-03-20 06:00:38 (1.01 MB/s) - `train-images-idx3-ubyte.gz' へ保存完了 [9912422/9912422]
gzip -c -d train-images-idx3-ubyte.gz > train-images-idx3-ubyte
wget http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
--2019-03-20 06:00:38-- http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 28881 (28K) [application/x-gzip]
`train-labels-idx1-ubyte.gz' に保存中
train-labels-idx1-u 100%[===================>] 28.20K 148KB/s 時間 0.2s
2019-03-20 06:00:39 (148 KB/s) - `train-labels-idx1-ubyte.gz' へ保存完了 [28881/28881]
gzip -c -d train-labels-idx1-ubyte.gz > train-labels-idx1-ubyte
wget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
--2019-03-20 06:00:39-- http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 1648877 (1.6M) [application/x-gzip]
`t10k-images-idx3-ubyte.gz' に保存中
t10k-images-idx3-ub 100%[===================>] 1.57M 463KB/s 時間 3.6s
2019-03-20 06:00:43 (443 KB/s) - `t10k-images-idx3-ubyte.gz' へ保存完了 [1648877/1648877]
gzip -c -d t10k-images-idx3-ubyte.gz > t10k-images-idx3-ubyte
wget http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
--2019-03-20 06:00:43-- http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
yann.lecun.com (yann.lecun.com) をDNSに問いあわせています... 216.165.22.6
yann.lecun.com (yann.lecun.com)|216.165.22.6|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 4542 (4.4K) [application/x-gzip]
`t10k-labels-idx1-ubyte.gz' に保存中
t10k-labels-idx1-ub 100%[===================>] 4.44K --.-KB/s 時間 0s
2019-03-20 06:00:43 (174 MB/s) - `t10k-labels-idx1-ubyte.gz' へ保存完了 [4542/4542]
gzip -c -d t10k-labels-idx1-ubyte.gz > t10k-labels-idx1-ubyte
./sample-mnist All
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {28, 28, 1} output shape : {1024}
------------------------------------------------------------------
[BatchNormalization]
input shape : {1024} output shape : {1024}
------------------------------------------------------------------
[ReLU]
input shape : {1024} output shape : {1024}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {1024} output shape : {360}
------------------------------------------------------------------
[BatchNormalization]
input shape : {360} output shape : {360}
------------------------------------------------------------------
[ReLU]
input shape : {360} output shape : {360}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {360} output shape : {60}
------------------------------------------------------------------
[BatchNormalization]
input shape : {60} output shape : {60}
------------------------------------------------------------------
[ReLU]
input shape : {60} output shape : {60}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {60} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutMlp
12.79s epoch[ 1] test_accuracy : 0.8074 train_accuracy : 0.8030
28.98s epoch[ 2] test_accuracy : 0.8771 train_accuracy : 0.8679
44.87s epoch[ 3] test_accuracy : 0.8801 train_accuracy : 0.8788
61.03s epoch[ 4] test_accuracy : 0.8647 train_accuracy : 0.8597
fitting end
lut_accuracy : 0.8647
export : MnistSimpleLutMlp.v
binary mode
----------------------------------------------------------------------
[Sequential]
--------------------------------------------------------------------
[RealToBinary]
input shape : {28, 28, 1} output shape : {28, 28, 1}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {28, 28, 1} output shape : {3, 3, 1}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 1} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {26, 26, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {26, 26, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {24, 24, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {24, 24, 32} output shape : {12, 12, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {12, 12, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {10, 10, 32}
--------------------------------------------------------------------
[LoweringConvolution]
------------------------------------------------------------------
[ConvolutionIm2Col]
input shape : {10, 10, 32} output shape : {3, 3, 32}
------------------------------------------------------------------
[Sequential]
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {3, 3, 32} output shape : {192}
--------------------------------------------------------------
[BatchNormalization]
input shape : {192} output shape : {192}
--------------------------------------------------------------
[ReLU]
input shape : {192} output shape : {192}
----------------------------------------------------------------
[MicroMlp]
--------------------------------------------------------------
[MicroMlpAffine]
input shape : {192} output shape : {32}
--------------------------------------------------------------
[BatchNormalization]
input shape : {32} output shape : {32}
--------------------------------------------------------------
[ReLU]
input shape : {32} output shape : {32}
------------------------------------------------------------------
[ConvolutionCol2Im]
input shape : {32} output shape : {8, 8, 32}
--------------------------------------------------------------------
[MaxPooling]
input shape : {8, 8, 32} output shape : {4, 4, 32}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {4, 4, 32} output shape : {480}
------------------------------------------------------------------
[BatchNormalization]
input shape : {480} output shape : {480}
------------------------------------------------------------------
[ReLU]
input shape : {480} output shape : {480}
--------------------------------------------------------------------
[MicroMlp]
------------------------------------------------------------------
[MicroMlpAffine]
input shape : {480} output shape : {80}
------------------------------------------------------------------
[BatchNormalization]
input shape : {80} output shape : {80}
------------------------------------------------------------------
[ReLU]
input shape : {80} output shape : {80}
--------------------------------------------------------------------
[BinaryToReal]
input shape : {80} output shape : {10}
----------------------------------------------------------------------
fitting start : MnistSimpleLutCnn
130.57s epoch[ 1] test_accuracy : 0.7246 train_accuracy : 0.7235
304.45s epoch[ 2] test_accuracy : 0.8018 train_accuracy : 0.7884
474.70s epoch[ 3] test_accuracy : 0.8517 train_accuracy : 0.8375
645.89s epoch[ 4] test_accuracy : 0.8854 train_accuracy : 0.8797
fitting end
fitting start : MnistDenseAffine
[initial] test_accuracy : 0.1566 train_accuracy : 0.1472
96.61s epoch[ 1] test_accuracy : 0.8704 train_accuracy : 0.8643
200.47s epoch[ 2] test_accuracy : 0.8979 train_accuracy : 0.9049
303.05s epoch[ 3] test_accuracy : 0.9138 train_accuracy : 0.9224
405.96s epoch[ 4] test_accuracy : 0.9237 train_accuracy : 0.9414
fitting end
accuracy : 0.153032
accuracy : 0.176794
accuracy : 0.207094
accuracy : 0.216566
docker run --runtime=nvidia -ti --rm --name binarybrainc --privileged -v /home/masaaki/Docker/BinaryBrain/BinaryBrain:/BinaryBrain binarybrain /bin/bash
root@6e7457d040c7:/BinaryBrain/sample/mnist# make WITH_CUDA=Yes all
make -C ../../cuda
make[1]: Entering directory '/BinaryBrain/cuda'
nvcc -c -I ../include Manager.cu -o Manager.o
In file included from /usr/include/c++/5/chrono:35:0,
from Manager.cu:2:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
Makefile:32: recipe for target 'Manager.o' failed
make[1]: *** [Manager.o] Error 1
make[1]: Leaving directory '/BinaryBrain/cuda'
Makefile:68: recipe for target 'bbcu_build' failed
make: *** [bbcu_build] Error 2
masaaki@masaaki-H110M4-M01:~/Docker$ docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
Unable to find image 'nvidia/cuda:9.0-base' locally
9.0-base: Pulling from nvidia/cuda
7b722c1070cd: Already exists
5fbf74db61f1: Already exists
ed41cb72e5c9: Already exists
7ea47a67709e: Already exists
52efd3da8bcd: Pull complete
eea82f174227: Pull complete
0d7845ca9ae6: Pull complete
Digest: sha256:6c77adf17b3e0188550afa02f88adc326195d845971a017c2317d0cf88f8b50b
Status: Downloaded newer image for nvidia/cuda:9.0-base
Mon Mar 18 19:04:06 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.116 Driver Version: 390.116 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 106... Off | 00000000:01:00.0 On | N/A |
| 33% 32C P8 10W / 120W | 540MiB / 6075MiB | 18% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
エラーになった。 transfer_learn/train がすでに存在することがだめらしい。mkdir: cannot create directory '/tensorflow/models/research/slim/transfer_learn/train': File exists
root@abedb1f7136c:/tensorflow/models/research/slim# ./start_training.sh --network_type mobilenet_v1 --train_whole_model true
+ network_type=mobilenet_v1
+ train_whole_model=false
+ train_steps=300
+ quantize_delay=100
+ [[ 4 -gt 0 ]]
+ case "$1" in
+ network_type=mobilenet_v1
+ shift 2
+ [[ 2 -gt 0 ]]
+ case "$1" in
+ train_whole_model=true
+ shift 2
+ [[ 0 -gt 0 ]]
+ source /tensorflow/models/research/slim/constants.sh
++ declare -A ckpt_link_map
++ declare -A ckpt_name_map
++ declare -A image_size_map
++ declare -A scopes_map
++ declare -A input_tensors_map
++ declare -A output_tensors_map
++ ckpt_link_map["mobilenet_v1"]=http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
++ ckpt_link_map["mobilenet_v2"]=http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz
++ ckpt_link_map["inception_v1"]=http://download.tensorflow.org/models/inception_v1_224_quant_20181026.tgz
++ ckpt_link_map["inception_v2"]=http://download.tensorflow.org/models/inception_v2_224_quant_20181026.tgz
++ ckpt_link_map["inception_v3"]=http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz
++ ckpt_link_map["inception_v4"]=http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz
++ ckpt_name_map["mobilenet_v1"]=mobilenet_v1_1.0_224_quant
++ ckpt_name_map["mobilenet_v2"]=mobilenet_v2_1.0_224_quant
++ ckpt_name_map["inception_v1"]=inception_v1_224_quant
++ ckpt_name_map["inception_v2"]=inception_v2_224_quant
++ ckpt_name_map["inception_v3"]=inception_v3_quant
++ ckpt_name_map["inception_v4"]=inception_v4_299_quant
++ image_size_map["mobilenet_v1"]=224
++ image_size_map["mobilenet_v2"]=224
++ image_size_map["inception_v1"]=224
++ image_size_map["inception_v2"]=224
++ image_size_map["inception_v3"]=299
++ image_size_map["inception_v4"]=299
++ scopes_map["mobilenet_v1"]=MobilenetV1/Logits
++ scopes_map["mobilenet_v2"]=MobilenetV2/Logits
++ scopes_map["inception_v1"]=InceptionV1/Logits
++ scopes_map["inception_v2"]=InceptionV2/Logits
++ scopes_map["inception_v3"]=InceptionV3/Logits,InceptionV3/AuxLogits
++ scopes_map["inception_v4"]=InceptionV4/Logits,InceptionV4/AuxLogits
++ input_tensors_map["mobilenet_v1"]=input
++ input_tensors_map["mobilenet_v2"]=input
++ input_tensors_map["inception_v1"]=input
++ input_tensors_map["inception_v2"]=input
++ input_tensors_map["inception_v3"]=input
++ input_tensors_map["inception_v4"]=input
++ output_tensors_map["mobilenet_v1"]=MobilenetV1/Predictions/Reshape_1
++ output_tensors_map["mobilenet_v2"]=MobilenetV2/Predictions/Softmax
++ output_tensors_map["inception_v1"]=InceptionV1/Logits/Predictions/Softmax
++ output_tensors_map["inception_v2"]=InceptionV2/Predictions/Reshape_1
++ output_tensors_map["inception_v3"]=InceptionV3/Predictions/Reshape_1
++ output_tensors_map["inception_v4"]=InceptionV4/Logits/Predictions
++ SLIM_DIR=/tensorflow/models/research/slim
++ LEARN_DIR=/tensorflow/models/research/slim/transfer_learn
++ CKPT_DIR=/tensorflow/models/research/slim/transfer_learn/ckpt
++ DATASET_DIR=/tensorflow/models/research/slim/transfer_learn/flowers
++ TRAIN_DIR=/tensorflow/models/research/slim/transfer_learn/train
++ OUTPUT_DIR=/tensorflow/models/research/slim/transfer_learn/models
+ mkdir /tensorflow/models/research/slim/transfer_learn/train
+ image_size=224
+ ckpt_name=mobilenet_v1_1.0_224_quant
+ scopes=MobilenetV1/Logits
+ [[ true == \t\r\u\e ]]
+ echo 'TRAINING all layers ...'
TRAINING all layers ...
+ python train_image_classifier.py --train_dir=/tensorflow/models/research/slim/transfer_learn/train --dataset_name=flowers --dataset_split_name=train --dataset_dir=/tensorflow/models/research/slim/transfer_learn/flowers --model_name=mobilenet_v1 --checkpoint_path=/tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt --max_number_of_steps=300 --batch_size=100 --learning_rate=0.01 --learning_rate_decay_type=fixed --save_interval_secs=60 --save_summaries_secs=60 --log_every_n_steps=20 --optimizer=sgd --weight_decay=0.00004 --quantize_delay=100 --clone_on_cpu --train_image_size=224 --checkpoint_exclude_scopes=MobilenetV1/Logits
WARNING:tensorflow:From train_image_classifier.py:413: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py:187: __init__ (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py:187: add_queue_runner (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From train_image_classifier.py:481: softmax_cross_entropy (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.softmax_cross_entropy instead. Note that the order of the logits and labels arguments has been changed.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:398: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.
See `tf.nn.softmax_cross_entropy_with_logits_v2`.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:399: compute_weighted_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.compute_weighted_loss instead.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:147: add_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.add_loss instead.
INFO:tensorflow:Fine-tuning from /tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/learning.py:737: __init__ (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.MonitoredTrainingSession
2019-03-14 19:43:50.952328: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:tensorflow:Restoring parameters from /tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Starting Session.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Starting Queues.
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:Recording summary at step 0.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0375885
INFO:tensorflow:Recording summary at step 2.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0673802
INFO:tensorflow:Recording summary at step 6.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0499222
INFO:tensorflow:Recording summary at step 9.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0500195
INFO:tensorflow:Recording summary at step 13.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0667236
INFO:tensorflow:Recording summary at step 16.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0500385
INFO:tensorflow:global step 20: loss = 0.7637 (21.146 sec/step)
INFO:tensorflow:Recording summary at step 20.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0666414
INFO:tensorflow:Recording summary at step 23.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0500105
INFO:tensorflow:Recording summary at step 26.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.0665609
INFO:tensorflow:Recording summary at step 30.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 33.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 36.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 39.
INFO:tensorflow:global step 40: loss = 0.7104 (25.263 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 43.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 45.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 49.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 52.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 56.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 59.
INFO:tensorflow:global step 60: loss = 0.5362 (20.882 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 62.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 65.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 68.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 71.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 75.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 78.
INFO:tensorflow:global step 80: loss = 0.5970 (15.896 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 81.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 84.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 88.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 91.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 95.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 98.
INFO:tensorflow:global step 100: loss = 0.5090 (14.821 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 102.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 105.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 108.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 112.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 115.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 119.
INFO:tensorflow:global step 120: loss = 0.4690 (15.645 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 122.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 125.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 128.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 131.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 134.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 138.
INFO:tensorflow:global step 140: loss = 0.2592 (15.237 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 141.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 144.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 147.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 151.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 154.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 157.
INFO:tensorflow:global step 160: loss = 0.3922 (14.742 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 161.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 164.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 168.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 171.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 175.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 178.
INFO:tensorflow:global step 180: loss = 0.2914 (14.689 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 182.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 185.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 189.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 192.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 196.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 199.
INFO:tensorflow:global step 200: loss = 0.5038 (22.475 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 203.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 206.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 210.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 213.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 217.
INFO:tensorflow:global step 220: loss = 0.3047 (15.426 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 220.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 223.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 227.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 230.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 233.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 236.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global step 240: loss = 0.3607 (24.436 sec/step)
INFO:tensorflow:Recording summary at step 240.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 243.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 246.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 249.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 252.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 256.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 259.
INFO:tensorflow:global step 260: loss = 0.2697 (23.522 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 263.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 266.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 270.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 273.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 277.
INFO:tensorflow:global step 280: loss = 0.2771 (14.920 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 280.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 284.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 287.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 290.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 294.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 297.
INFO:tensorflow:global step 300: loss = 0.2972 (14.734 sec/step)
INFO:tensorflow:Stopping Training.
INFO:tensorflow:Finished training! Saving model to disk.
のプロンプトが表示された。root@abedb1f7136c:/tensorflow/models/research/slim#
root@abedb1f7136c:/tensorflow/models/research/slim# ./prepare_checkpoint_and_dataset.sh --network_type mobilenet_v1
+ network_type=mobilenet_v1
+ [[ 2 -gt 0 ]]
+ case "$1" in
+ network_type=mobilenet_v1
+ shift 2
+ [[ 0 -gt 0 ]]
+ source /tensorflow/models/research/slim/constants.sh
++ declare -A ckpt_link_map
++ declare -A ckpt_name_map
++ declare -A image_size_map
++ declare -A scopes_map
++ declare -A input_tensors_map
++ declare -A output_tensors_map
++ ckpt_link_map["mobilenet_v1"]=http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
++ ckpt_link_map["mobilenet_v2"]=http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz
++ ckpt_link_map["inception_v1"]=http://download.tensorflow.org/models/inception_v1_224_quant_20181026.tgz
++ ckpt_link_map["inception_v2"]=http://download.tensorflow.org/models/inception_v2_224_quant_20181026.tgz
++ ckpt_link_map["inception_v3"]=http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz
++ ckpt_link_map["inception_v4"]=http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz
++ ckpt_name_map["mobilenet_v1"]=mobilenet_v1_1.0_224_quant
++ ckpt_name_map["mobilenet_v2"]=mobilenet_v2_1.0_224_quant
++ ckpt_name_map["inception_v1"]=inception_v1_224_quant
++ ckpt_name_map["inception_v2"]=inception_v2_224_quant
++ ckpt_name_map["inception_v3"]=inception_v3_quant
++ ckpt_name_map["inception_v4"]=inception_v4_299_quant
++ image_size_map["mobilenet_v1"]=224
++ image_size_map["mobilenet_v2"]=224
++ image_size_map["inception_v1"]=224
++ image_size_map["inception_v2"]=224
++ image_size_map["inception_v3"]=299
++ image_size_map["inception_v4"]=299
++ scopes_map["mobilenet_v1"]=MobilenetV1/Logits
++ scopes_map["mobilenet_v2"]=MobilenetV2/Logits
++ scopes_map["inception_v1"]=InceptionV1/Logits
++ scopes_map["inception_v2"]=InceptionV2/Logits
++ scopes_map["inception_v3"]=InceptionV3/Logits,InceptionV3/AuxLogits
++ scopes_map["inception_v4"]=InceptionV4/Logits,InceptionV4/AuxLogits
++ input_tensors_map["mobilenet_v1"]=input
++ input_tensors_map["mobilenet_v2"]=input
++ input_tensors_map["inception_v1"]=input
++ input_tensors_map["inception_v2"]=input
++ input_tensors_map["inception_v3"]=input
++ input_tensors_map["inception_v4"]=input
++ output_tensors_map["mobilenet_v1"]=MobilenetV1/Predictions/Reshape_1
++ output_tensors_map["mobilenet_v2"]=MobilenetV2/Predictions/Softmax
++ output_tensors_map["inception_v1"]=InceptionV1/Logits/Predictions/Softmax
++ output_tensors_map["inception_v2"]=InceptionV2/Predictions/Reshape_1
++ output_tensors_map["inception_v3"]=InceptionV3/Predictions/Reshape_1
++ output_tensors_map["inception_v4"]=InceptionV4/Logits/Predictions
++ SLIM_DIR=/tensorflow/models/research/slim
++ LEARN_DIR=/tensorflow/models/research/slim/transfer_learn
++ CKPT_DIR=/tensorflow/models/research/slim/transfer_learn/ckpt
++ DATASET_DIR=/tensorflow/models/research/slim/transfer_learn/flowers
++ TRAIN_DIR=/tensorflow/models/research/slim/transfer_learn/train
++ OUTPUT_DIR=/tensorflow/models/research/slim/transfer_learn/models
+ echo 'PREPARING checkpoint ...'
PREPARING checkpoint ...
+ mkdir -p /tensorflow/models/research/slim/transfer_learn
+ mkdir /tensorflow/models/research/slim/transfer_learn/ckpt
+ cd /tensorflow/models/research/slim/transfer_learn/ckpt
+ ckpt_link=http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
+ ckpt_name=mobilenet_v1_1.0_224_quant
+ wget -O mobilenet_v1_1.0_224_quant.tgz http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
--2019-03-12 11:22:56-- http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
Resolving download.tensorflow.org (download.tensorflow.org)... 172.217.25.208, 2404:6800:4004:818::2010
Connecting to download.tensorflow.org (download.tensorflow.org)|172.217.25.208|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35069912 (33M) [application/x-compressed-tar]
Saving to: 'mobilenet_v1_1.0_224_quant.tgz'
mobilenet_v1_1.0_22 100%[===================>] 33.44M 9.83MB/s in 3.4s
2019-03-12 11:23:00 (9.83 MB/s) - 'mobilenet_v1_1.0_224_quant.tgz' saved [35069912/35069912]
+ tar zxvf mobilenet_v1_1.0_224_quant.tgz
./
./mobilenet_v1_1.0_224_quant.ckpt.index
./mobilenet_v1_1.0_224_quant_eval.pbtxt
./mobilenet_v1_1.0_224_quant_info.txt
./mobilenet_v1_1.0_224_quant.ckpt.data-00000-of-00001
./mobilenet_v1_1.0_224_quant.tflite
./mobilenet_v1_1.0_224_quant.ckpt.meta
./mobilenet_v1_1.0_224_quant_frozen.pb
+ echo 'PREPARING dataset ...'
PREPARING dataset ...
+ mkdir /tensorflow/models/research/slim/transfer_learn/flowers
+ cd /tensorflow/models/research/slim
+ python download_and_convert_data.py --dataset_name=flowers --dataset_dir=/tensorflow/models/research/slim/transfer_learn/flowers
>> Downloading flower_photos.tgz 100.0%
Successfully downloaded flower_photos.tgz 228813984 bytes.
2019-03-12 11:23:25.559151: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>> Converting image 3320/3320 shard 4
>> Converting image 350/350 shard 4
Finished converting the Flowers dataset!
+ echo 'CHECKPOINT and dataset available in /tensorflow/models/research/slim/transfer_learn'
CHECKPOINT and dataset available in /tensorflow/models/research/slim/transfer_learn
root@abedb1f7136c:/tensorflow/models/research/slim# ./start_training.sh --network_type mobilenet_v1
+ network_type=mobilenet_v1
+ train_whole_model=false
+ train_steps=300
+ quantize_delay=100
+ [[ 2 -gt 0 ]]
+ case "$1" in
+ network_type=mobilenet_v1
+ shift 2
+ [[ 0 -gt 0 ]]
+ source /tensorflow/models/research/slim/constants.sh
++ declare -A ckpt_link_map
++ declare -A ckpt_name_map
++ declare -A image_size_map
++ declare -A scopes_map
++ declare -A input_tensors_map
++ declare -A output_tensors_map
++ ckpt_link_map["mobilenet_v1"]=http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz
++ ckpt_link_map["mobilenet_v2"]=http://download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz
++ ckpt_link_map["inception_v1"]=http://download.tensorflow.org/models/inception_v1_224_quant_20181026.tgz
++ ckpt_link_map["inception_v2"]=http://download.tensorflow.org/models/inception_v2_224_quant_20181026.tgz
++ ckpt_link_map["inception_v3"]=http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz
++ ckpt_link_map["inception_v4"]=http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz
++ ckpt_name_map["mobilenet_v1"]=mobilenet_v1_1.0_224_quant
++ ckpt_name_map["mobilenet_v2"]=mobilenet_v2_1.0_224_quant
++ ckpt_name_map["inception_v1"]=inception_v1_224_quant
++ ckpt_name_map["inception_v2"]=inception_v2_224_quant
++ ckpt_name_map["inception_v3"]=inception_v3_quant
++ ckpt_name_map["inception_v4"]=inception_v4_299_quant
++ image_size_map["mobilenet_v1"]=224
++ image_size_map["mobilenet_v2"]=224
++ image_size_map["inception_v1"]=224
++ image_size_map["inception_v2"]=224
++ image_size_map["inception_v3"]=299
++ image_size_map["inception_v4"]=299
++ scopes_map["mobilenet_v1"]=MobilenetV1/Logits
++ scopes_map["mobilenet_v2"]=MobilenetV2/Logits
++ scopes_map["inception_v1"]=InceptionV1/Logits
++ scopes_map["inception_v2"]=InceptionV2/Logits
++ scopes_map["inception_v3"]=InceptionV3/Logits,InceptionV3/AuxLogits
++ scopes_map["inception_v4"]=InceptionV4/Logits,InceptionV4/AuxLogits
++ input_tensors_map["mobilenet_v1"]=input
++ input_tensors_map["mobilenet_v2"]=input
++ input_tensors_map["inception_v1"]=input
++ input_tensors_map["inception_v2"]=input
++ input_tensors_map["inception_v3"]=input
++ input_tensors_map["inception_v4"]=input
++ output_tensors_map["mobilenet_v1"]=MobilenetV1/Predictions/Reshape_1
++ output_tensors_map["mobilenet_v2"]=MobilenetV2/Predictions/Softmax
++ output_tensors_map["inception_v1"]=InceptionV1/Logits/Predictions/Softmax
++ output_tensors_map["inception_v2"]=InceptionV2/Predictions/Reshape_1
++ output_tensors_map["inception_v3"]=InceptionV3/Predictions/Reshape_1
++ output_tensors_map["inception_v4"]=InceptionV4/Logits/Predictions
++ SLIM_DIR=/tensorflow/models/research/slim
++ LEARN_DIR=/tensorflow/models/research/slim/transfer_learn
++ CKPT_DIR=/tensorflow/models/research/slim/transfer_learn/ckpt
++ DATASET_DIR=/tensorflow/models/research/slim/transfer_learn/flowers
++ TRAIN_DIR=/tensorflow/models/research/slim/transfer_learn/train
++ OUTPUT_DIR=/tensorflow/models/research/slim/transfer_learn/models
+ mkdir /tensorflow/models/research/slim/transfer_learn/train
+ image_size=224
+ ckpt_name=mobilenet_v1_1.0_224_quant
+ scopes=MobilenetV1/Logits
+ [[ false == \t\r\u\e ]]
+ echo 'TRAINING last few layers ...'
TRAINING last few layers ...
+ python train_image_classifier.py --train_dir=/tensorflow/models/research/slim/transfer_learn/train --dataset_name=flowers --dataset_split_name=train --dataset_dir=/tensorflow/models/research/slim/transfer_learn/flowers --model_name=mobilenet_v1 --checkpoint_path=/tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt --max_number_of_steps=300 --batch_size=100 --learning_rate=0.01 --learning_rate_decay_type=fixed --save_interval_secs=60 --save_summaries_secs=60 --log_every_n_steps=20 --optimizer=sgd --weight_decay=0.00004 --quantize_delay=100 --clone_on_cpu --train_image_size=224 --checkpoint_exclude_scopes=MobilenetV1/Logits --trainable_scopes=MobilenetV1/Logits
WARNING:tensorflow:From train_image_classifier.py:413: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py:187: __init__ (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py:187: add_queue_runner (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From train_image_classifier.py:481: softmax_cross_entropy (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.softmax_cross_entropy instead. Note that the order of the logits and labels arguments has been changed.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:398: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.
See `tf.nn.softmax_cross_entropy_with_logits_v2`.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:399: compute_weighted_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.compute_weighted_loss instead.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:147: add_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.add_loss instead.
INFO:tensorflow:Fine-tuning from /tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/learning.py:737: __init__ (from tensorflow.python.training.supervisor) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.MonitoredTrainingSession
2019-03-12 11:27:30.706494: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:tensorflow:Restoring parameters from /tensorflow/models/research/slim/transfer_learn/ckpt/mobilenet_v1_1.0_224_quant.ckpt
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Starting Session.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Starting Queues.
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:Recording summary at step 1.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.134039
INFO:tensorflow:Recording summary at step 9.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.149296
INFO:tensorflow:Recording summary at step 18.
INFO:tensorflow:global step 20: loss = 1.8288 (5.751 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.150273
INFO:tensorflow:Recording summary at step 27.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.150492
INFO:tensorflow:Recording summary at step 36.
INFO:tensorflow:global step 40: loss = 1.2239 (5.355 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.147502
INFO:tensorflow:Recording summary at step 45.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.15272
INFO:tensorflow:Recording summary at step 54.
INFO:tensorflow:global step 60: loss = 1.0667 (5.793 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.149623
INFO:tensorflow:Recording summary at step 63.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.13363
INFO:tensorflow:Recording summary at step 72.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global_step/sec: 0.14869
INFO:tensorflow:global step 80: loss = 0.8747 (9.908 sec/step)
INFO:tensorflow:Recording summary at step 80.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 89.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 99.
INFO:tensorflow:global step 100: loss = 0.9789 (5.818 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 108.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 117.
INFO:tensorflow:global step 120: loss = 0.7836 (5.771 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 126.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 135.
INFO:tensorflow:global step 140: loss = 0.7582 (5.641 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 144.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 153.
INFO:tensorflow:global step 160: loss = 0.7289 (5.561 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 162.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 171.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:global step 180: loss = 0.7996 (8.771 sec/step)
INFO:tensorflow:Recording summary at step 180.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 190.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 199.
INFO:tensorflow:global step 200: loss = 0.6564 (6.531 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 208.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 217.
INFO:tensorflow:global step 220: loss = 0.7724 (5.751 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 226.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 236.
INFO:tensorflow:global step 240: loss = 0.7227 (5.387 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 245.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 255.
INFO:tensorflow:global step 260: loss = 0.7362 (5.324 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 264.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 274.
INFO:tensorflow:global step 280: loss = 0.5858 (5.351 sec/step)
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 283.
INFO:tensorflow:Saving checkpoint to path /tensorflow/models/research/slim/transfer_learn/train/model.ckpt
INFO:tensorflow:Recording summary at step 293.
INFO:tensorflow:global step 300: loss = 0.6365 (5.394 sec/step)
INFO:tensorflow:Stopping Training.
INFO:tensorflow:Finished training! Saving model to disk.
masaaki@masaaki-H110M4-M01:~/python-tflite-source/edgetpu$ python3 demo/object_detection.py \
> --model='test_data/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite' \
> --input='test_data/face.jpg'
-----------------------------------------
score = 0.99609375
box = [474.22854804992676, 38.03488787482766, 738.8013491630554, 353.5309683683231]
-----------------------------------------
score = 0.99609375
box = [205.4297697544098, 110.28378465056959, 487.75309658050537, 439.73802454331343]
-----------------------------------------
score = 0.83203125
box = [7.522284880280495, 183.90177454883695, 125.84126299619675, 324.99404113217173]
-----------------------------------------
score = 0.5
box = [859.8422718048096, 213.5472493581642, 1008.978108882904, 383.9367261515483]
Traceback (most recent call last):
File "classification_transfer_learning.py", line 210, in <module>
main()
File "classification_transfer_learning.py", line 179, in main
labels_map = engine.TrainAll(train_input)
File "/home/masaaki/python-tflite-source/edgetpu/learn/imprinting/engine.py", line 20, in TrainAll
ret[self.Train(tensors)] = category
File "/home/masaaki/python-tflite-source/edgetpu/swig/edgetpu_cpp_wrapper.py", line 175, in Train
return _edgetpu_cpp_wrapper.ImprintingEngine_Train(self, input)
TypeError: Cannot cast array data from dtype('O') to dtype('uint8') according to the rule 'safe'
masaaki@masaaki-H110M4-M01:~/python-tflite-source/edgetpu$ python3 demo/object_detection.py \
> --model='test_data/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite' \
> --label='test_data/coco_labels.txt' \
> --input='test_data/open_image_v4_subset/Cat/4278078325_fe95b2d365_o.jpg'
-----------------------------------------
cat
score = 0.7890625
box = [544.3585515022278, 161.8559150240529, 906.7766070365906, 574.1258810512984]
-----------------------------------------
cat
score = 0.5
box = [544.8259115219116, 180.16657727447586, 780.6186676025391, 557.7862670074156]
-----------------------------------------
bench
score = 0.16015625
box = [0.0, 286.536341216696, 1000.0, 664.0]
-----------------------------------------
cup
score = 0.12109375
box = [927.8294444084167, 9.622623872517341, 996.2391257286072, 125.93606662510628]
-----------------------------------------
car
score = 0.12109375
box = [347.52047061920166, 159.55350482883165, 548.1888055801392, 321.0489713965948]
-----------------------------------------
bench
score = 0.12109375
box = [3.985762596130371, 350.9136437171668, 989.7855520248413, 664.0]
-----------------------------------------
cup
score = 0.12109375
box = [829.7642469406128, 9.965896396780732, 932.0130348205566, 139.7531082881755]
-----------------------------------------
bench
score = 0.12109375
box = [17.50752329826355, 482.14271655633826, 998.0459213256836, 664.0]
-----------------------------------------
bench
score = 0.12109375
box = [0.0, 0.0, 339.12184834480286, 514.3285784889106]
-----------------------------------------
cat
score = 0.08984375
box = [407.7613055706024, 186.5492222297132, 986.0997200012207, 610.9205907313668]
今日はマスク付けて走ります。 pic.twitter.com/RQqbsiMZBY
— marsee101 (@marsee101) 2019年3月10日
100 円焼きそばです。もう終わりで安くなっていました。 pic.twitter.com/SQkU5gQhzt
— marsee101 (@marsee101) 2019年3月10日
# 畳み込み層の重みをCヘッダファイルに書き出す
# 2018/05/31 by marsee
def fwrite_conv_weight(weight, wfile_name, float_wt_name, fixed_wt_name, MAGNIFICATION):
import datetime
import numpy as np
f = open(wfile_name, 'w')
todaytime = datetime.datetime.today()
f.write('// '+wfile_name+'\n')
strdtime = todaytime.strftime("%Y/%m/%d %H:%M:%S")
f.write('// {0} by marsee\n'.format(strdtime))
f.write("\n")
f.write('const float '+float_wt_name+'['+str(weight.shape[0])+']['+str(weight.shape[1])+']['+str(weight.shape[2])+']['+str(weight.shape[3])+'] = \n{\n')
for i in range(weight.shape[0]):
f.write("\t{\n")
for j in range(weight.shape[1]):
f.write("\t\t{\n")
for k in range(weight.shape[2]):
f.write("\t\t\t{")
for m in range(weight.shape[3]):
f.write(str(weight[i][j][k][m]))
if (m==weight.shape[3]-1):
f.write("}")
else:
f.write(",")
if (k==weight.shape[2]-1):
f.write("\n\t\t}\n")
else:
f.write(",\n")
if (j==weight.shape[1]-1):
f.write("\t}\n")
else:
f.write(",\n")
if (i==weight.shape[0]-1):
f.write("};\n")
else:
f.write("\t,\n")
f.write("\n")
f.write('const ap_fixed<'+str(int(np.log2(MAGNIFICATION))+1)+', 1, AP_TRN, AP_WRAP> '+fixed_wt_name+'['+str(weight.shape[0])+']['+str(weight.shape[1])+']['+str(weight.shape[2])+']['+str(weight.shape[3])+'] = \n{\n')
for i in range(weight.shape[0]):
f.write("\t{\n")
for j in range(weight.shape[1]):
f.write("\t\t{\n")
for k in range(weight.shape[2]):
f.write("\t\t\t{")
for m in range(weight.shape[3]):
w_int = int(weight[i][j][k][m]*MAGNIFICATION+0.5)
if (w_int > MAGNIFICATION-1):
w_int = MAGNIFICATION-1
elif (w_int < -MAGNIFICATION):
w_int = -MAGNIFICATION
f.write(str(float(w_int)/float(MAGNIFICATION)))
if (m==weight.shape[3]-1):
f.write("}")
else:
f.write(",")
if (k==weight.shape[2]-1):
f.write("\n\t\t}\n")
else:
f.write(",\n")
if (j==weight.shape[1]-1):
f.write("\t}\n")
else:
f.write(",\n")
if (i==weight.shape[0]-1):
f.write("};\n")
else:
f.write("\t,\n")
f.close()
# 2018/06/05 修正 畳み込み層の重みの配列は(カーネルサイズh,カーネルサイズw, 入力チャネル, 出力チャネル)ということなので、Pythonコードを修正した。@NORA__0013 さんありがとうございました。
# 畳み込み層第1層目
MAGNIFICATION_CONV = 2 ** (9-1)
fwrite_conv_weight(conv_layer_weight.transpose(3,2,0,1), 'conv1_weight.h', 'conv1_fweight', 'conv1_weight', MAGNIFICATION_CONV)
# 畳み込み層第2層目
MAGNIFICATION_CONV = 2 ** (9-1)
fwrite_conv_weight(conv_layer2_weight.transpose(3,2,0,1), 'conv2_weight.h', 'conv2_fweight', 'conv2_weight', MAGNIFICATION_CONV)
# 畳み込み層と全結合層のバイアスをCヘッダファイルに書き出す
# 2018/05/31 by marsee
def fwrite_bias(bias, wfile_name, float_b_name, fixed_wt_name, MAGNIFICATION):
import datetime
import numpy as np
f = open(wfile_name, 'w')
todaytime = datetime.datetime.today()
f.write('// '+wfile_name+'\n')
strdtime = todaytime.strftime("%Y/%m/%d %H:%M:%S")
f.write('// {0} by marsee\n'.format(strdtime))
f.write("\n")
f.write('const float '+float_b_name+'['+str(bias.shape[0])+'] = {\n\t')
for i in range(bias.shape[0]):
f.write(str(bias[i]))
if (i < bias.shape[0]-1):
f.write(", ")
f.write("\n};\n")
f.write("\n")
f.write('const ap_fixed<'+str(int(np.log2(MAGNIFICATION))+1)+', 1, AP_TRN, AP_WRAP> '+fixed_wt_name+'['+str(bias.shape[0])+'] = {\n\t')
for i in range(bias.shape[0]):
b_int = int(bias[i]*MAGNIFICATION+0.5)
if (b_int > MAGNIFICATION-1):
b_int = MAGNIFICATION-1
elif (b_int < -MAGNIFICATION):
b_int = -MAGNIFICATION
f.write(str(float(b_int)/float(MAGNIFICATION)))
if (i < bias.shape[0]-1):
f.write(", ")
f.write("\n};\n")
f.close()
fwrite_bias(conv_layer_bias, 'conv1_bias.h', 'conv1_fbias', 'conv1_bias', MAGNIFICATION_CONV)
fwrite_bias(conv_layer2_bias, 'conv2_bias.h', 'conv2_fbias', 'conv2_bias', MAGNIFICATION_CONV)
root@d97b3c148a5b:/srv/keras_compressor/example/cifar10# python3 evaluate.py model_raw.h5
Using TensorFlow backend.
2019-03-04 19:57:25.202654: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 32, 32, 3) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 32, 32, 64) 1792
_________________________________________________________________
batch_normalization_1 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
dropout_1 (Dropout) (None, 32, 32, 64) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 32, 32, 64) 36928
_________________________________________________________________
batch_normalization_2 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 16, 16, 64) 0
_________________________________________________________________
conv2d_3 (Conv2D) (None, 16, 16, 128) 73856
_________________________________________________________________
batch_normalization_3 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
dropout_2 (Dropout) (None, 16, 16, 128) 0
_________________________________________________________________
conv2d_4 (Conv2D) (None, 16, 16, 128) 147584
_________________________________________________________________
batch_normalization_4 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 8, 8, 128) 0
_________________________________________________________________
conv2d_5 (Conv2D) (None, 8, 8, 256) 295168
_________________________________________________________________
batch_normalization_5 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_3 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_6 (Conv2D) (None, 8, 8, 256) 590080
_________________________________________________________________
batch_normalization_6 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_4 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_7 (Conv2D) (None, 8, 8, 256) 590080
_________________________________________________________________
batch_normalization_7 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 4, 4, 256) 0
_________________________________________________________________
conv2d_8 (Conv2D) (None, 4, 4, 512) 1180160
_________________________________________________________________
batch_normalization_8 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_5 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_9 (Conv2D) (None, 4, 4, 512) 2359808
_________________________________________________________________
batch_normalization_9 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_6 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_10 (Conv2D) (None, 4, 4, 512) 2359808
_________________________________________________________________
batch_normalization_10 (Batc (None, 4, 4, 512) 2048
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_11 (Conv2D) (None, 2, 2, 512) 2359808
_________________________________________________________________
batch_normalization_11 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_7 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_12 (Conv2D) (None, 2, 2, 512) 2359808
_________________________________________________________________
batch_normalization_12 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_8 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_13 (Conv2D) (None, 2, 2, 512) 2359808
_________________________________________________________________
batch_normalization_13 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 1, 1, 512) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 512) 0
_________________________________________________________________
dropout_9 (Dropout) (None, 512) 0
_________________________________________________________________
dense_1 (Dense) (None, 512) 262656
_________________________________________________________________
batch_normalization_14 (Batc (None, 512) 2048
_________________________________________________________________
dropout_10 (Dropout) (None, 512) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 5130
=================================================================
Total params: 15,001,418
Trainable params: 14,991,946
Non-trainable params: 9,472
_________________________________________________________________
[0.4078139572441578, 0.8732]
root@d97b3c148a5b:/srv/keras_compressor/example/cifar10# python3 evaluate.py model_compressed.h5
Using TensorFlow backend.
2019-03-04 20:01:08.106457: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 32, 32, 3) 0
_________________________________________________________________
conv2d_1 (FactorizedConv2DTu (None, 32, 32, 64) 1429
_________________________________________________________________
batch_normalization_1 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
dropout_1 (Dropout) (None, 32, 32, 64) 0
_________________________________________________________________
conv2d_2 (FactorizedConv2DTu (None, 32, 32, 64) 24384
_________________________________________________________________
batch_normalization_2 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 16, 16, 64) 0
_________________________________________________________________
conv2d_3 (FactorizedConv2DTu (None, 16, 16, 128) 47552
_________________________________________________________________
batch_normalization_3 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
dropout_2 (Dropout) (None, 16, 16, 128) 0
_________________________________________________________________
conv2d_4 (FactorizedConv2DTu (None, 16, 16, 128) 116608
_________________________________________________________________
batch_normalization_4 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 8, 8, 128) 0
_________________________________________________________________
conv2d_5 (FactorizedConv2DTu (None, 8, 8, 256) 204544
_________________________________________________________________
batch_normalization_5 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_3 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_6 (FactorizedConv2DTu (None, 8, 8, 256) 404736
_________________________________________________________________
batch_normalization_6 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_4 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_7 (FactorizedConv2DTu (None, 8, 8, 256) 371456
_________________________________________________________________
batch_normalization_7 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 4, 4, 256) 0
_________________________________________________________________
conv2d_8 (FactorizedConv2DTu (None, 4, 4, 512) 406377
_________________________________________________________________
batch_normalization_8 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_5 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_9 (FactorizedConv2DTu (None, 4, 4, 512) 1300992
_________________________________________________________________
batch_normalization_9 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_6 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_10 (FactorizedConv2DT (None, 4, 4, 512) 394752
_________________________________________________________________
batch_normalization_10 (Batc (None, 4, 4, 512) 2048
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_11 (FactorizedConv2DT (None, 2, 2, 512) 103437
_________________________________________________________________
batch_normalization_11 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_7 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_12 (FactorizedConv2DT (None, 2, 2, 512) 1326592
_________________________________________________________________
batch_normalization_12 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_8 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_13 (FactorizedConv2DT (None, 2, 2, 512) 1260032
_________________________________________________________________
batch_normalization_13 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 1, 1, 512) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 512) 0
_________________________________________________________________
dropout_9 (Dropout) (None, 512) 0
_________________________________________________________________
dense_1 (FactorizedDense) (None, 512) 190976
_________________________________________________________________
batch_normalization_14 (Batc (None, 512) 2048
_________________________________________________________________
dropout_10 (Dropout) (None, 512) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 5130
=================================================================
Total params: 6,177,941
Trainable params: 6,168,469
Non-trainable params: 9,472
_________________________________________________________________
[0.7183663519859314, 0.7791]
root@d97b3c148a5b:/srv/keras_compressor/example/cifar10# python3 evaluate.py model_finetuned.h5
Using TensorFlow backend.
2019-03-04 20:03:16.616118: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 32, 32, 3) 0
_________________________________________________________________
conv2d_1 (FactorizedConv2DTu (None, 32, 32, 64) 1429
_________________________________________________________________
batch_normalization_1 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
dropout_1 (Dropout) (None, 32, 32, 64) 0
_________________________________________________________________
conv2d_2 (FactorizedConv2DTu (None, 32, 32, 64) 24384
_________________________________________________________________
batch_normalization_2 (Batch (None, 32, 32, 64) 256
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 16, 16, 64) 0
_________________________________________________________________
conv2d_3 (FactorizedConv2DTu (None, 16, 16, 128) 47552
_________________________________________________________________
batch_normalization_3 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
dropout_2 (Dropout) (None, 16, 16, 128) 0
_________________________________________________________________
conv2d_4 (FactorizedConv2DTu (None, 16, 16, 128) 116608
_________________________________________________________________
batch_normalization_4 (Batch (None, 16, 16, 128) 512
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 8, 8, 128) 0
_________________________________________________________________
conv2d_5 (FactorizedConv2DTu (None, 8, 8, 256) 204544
_________________________________________________________________
batch_normalization_5 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_3 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_6 (FactorizedConv2DTu (None, 8, 8, 256) 404736
_________________________________________________________________
batch_normalization_6 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
dropout_4 (Dropout) (None, 8, 8, 256) 0
_________________________________________________________________
conv2d_7 (FactorizedConv2DTu (None, 8, 8, 256) 371456
_________________________________________________________________
batch_normalization_7 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 4, 4, 256) 0
_________________________________________________________________
conv2d_8 (FactorizedConv2DTu (None, 4, 4, 512) 406377
_________________________________________________________________
batch_normalization_8 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_5 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_9 (FactorizedConv2DTu (None, 4, 4, 512) 1300992
_________________________________________________________________
batch_normalization_9 (Batch (None, 4, 4, 512) 2048
_________________________________________________________________
dropout_6 (Dropout) (None, 4, 4, 512) 0
_________________________________________________________________
conv2d_10 (FactorizedConv2DT (None, 4, 4, 512) 394752
_________________________________________________________________
batch_normalization_10 (Batc (None, 4, 4, 512) 2048
_________________________________________________________________
max_pooling2d_4 (MaxPooling2 (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_11 (FactorizedConv2DT (None, 2, 2, 512) 103437
_________________________________________________________________
batch_normalization_11 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_7 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_12 (FactorizedConv2DT (None, 2, 2, 512) 1326592
_________________________________________________________________
batch_normalization_12 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
dropout_8 (Dropout) (None, 2, 2, 512) 0
_________________________________________________________________
conv2d_13 (FactorizedConv2DT (None, 2, 2, 512) 1260032
_________________________________________________________________
batch_normalization_13 (Batc (None, 2, 2, 512) 2048
_________________________________________________________________
max_pooling2d_5 (MaxPooling2 (None, 1, 1, 512) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 512) 0
_________________________________________________________________
dropout_9 (Dropout) (None, 512) 0
_________________________________________________________________
dense_1 (FactorizedDense) (None, 512) 190976
_________________________________________________________________
batch_normalization_14 (Batc (None, 512) 2048
_________________________________________________________________
dropout_10 (Dropout) (None, 512) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 5130
=================================================================
Total params: 6,177,941
Trainable params: 6,168,469
Non-trainable params: 9,472
_________________________________________________________________
[0.4548675367474556, 0.8746]
root@7552a77f8bdb:/srv/keras_compressor/example/cifar10# python3 train.py
Using TensorFlow backend.
Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
170500096/170498071 [==============================] - 43s 0us/step
2019-02-27 11:54:10.618893: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Epoch 1/30
390/390 [==============================] - 1912s 5s/step - loss: 2.4666 - acc: 0.2015 - val_loss: 7.8723 - val_acc: 0.1599
Epoch 2/30
390/390 [==============================] - 1951s 5s/step - loss: 1.7865 - acc: 0.3543 - val_loss: 1.7953 - val_acc: 0.4245
Epoch 3/30
390/390 [==============================] - 1884s 5s/step - loss: 1.4745 - acc: 0.4727 - val_loss: 1.4443 - val_acc: 0.5675
Epoch 4/30
390/390 [==============================] - 1782s 5s/step - loss: 1.2430 - acc: 0.5594 - val_loss: 1.3947 - val_acc: 0.5735
Epoch 5/30
390/390 [==============================] - 1748s 4s/step - loss: 1.0835 - acc: 0.6209 - val_loss: 1.3739 - val_acc: 0.6071
Epoch 6/30
390/390 [==============================] - 1745s 4s/step - loss: 0.9651 - acc: 0.6626 - val_loss: 1.0916 - val_acc: 0.6663
Epoch 7/30
390/390 [==============================] - 1752s 4s/step - loss: 0.8771 - acc: 0.6987 - val_loss: 1.0480 - val_acc: 0.6722
Epoch 8/30
390/390 [==============================] - 1752s 4s/step - loss: 0.8071 - acc: 0.7265 - val_loss: 0.8734 - val_acc: 0.7279
Epoch 9/30
390/390 [==============================] - 1749s 4s/step - loss: 0.7478 - acc: 0.7471 - val_loss: 1.0155 - val_acc: 0.7233
Epoch 10/30
390/390 [==============================] - 1749s 4s/step - loss: 0.6909 - acc: 0.7667 - val_loss: 0.7561 - val_acc: 0.7607
Epoch 11/30
390/390 [==============================] - 1749s 4s/step - loss: 0.6446 - acc: 0.7844 - val_loss: 0.6690 - val_acc: 0.7949
Epoch 12/30
390/390 [==============================] - 1747s 4s/step - loss: 0.6114 - acc: 0.7944 - val_loss: 0.7836 - val_acc: 0.7496
Epoch 13/30
390/390 [==============================] - 1747s 4s/step - loss: 0.5827 - acc: 0.8051 - val_loss: 0.5952 - val_acc: 0.8103
Epoch 14/30
390/390 [==============================] - 1801s 5s/step - loss: 0.5528 - acc: 0.8158 - val_loss: 0.5906 - val_acc: 0.8136
Epoch 15/30
390/390 [==============================] - 1961s 5s/step - loss: 0.5323 - acc: 0.8242 - val_loss: 0.6216 - val_acc: 0.8075
Epoch 16/30
390/390 [==============================] - 1902s 5s/step - loss: 0.5109 - acc: 0.8314 - val_loss: 0.5732 - val_acc: 0.8223
Epoch 17/30
390/390 [==============================] - 1934s 5s/step - loss: 0.4924 - acc: 0.8364 - val_loss: 0.4982 - val_acc: 0.8401
Epoch 18/30
390/390 [==============================] - 1935s 5s/step - loss: 0.4725 - acc: 0.8434 - val_loss: 0.4574 - val_acc: 0.8530
Epoch 19/30
390/390 [==============================] - 1795s 5s/step - loss: 0.4565 - acc: 0.8500 - val_loss: 0.5249 - val_acc: 0.8385
Epoch 20/30
390/390 [==============================] - 1901s 5s/step - loss: 0.4390 - acc: 0.8550 - val_loss: 0.4785 - val_acc: 0.8479
Epoch 21/30
390/390 [==============================] - 1809s 5s/step - loss: 0.4292 - acc: 0.8586 - val_loss: 0.4610 - val_acc: 0.8519
Epoch 22/30
390/390 [==============================] - 1774s 5s/step - loss: 0.4165 - acc: 0.8628 - val_loss: 0.4749 - val_acc: 0.8519
Epoch 23/30
390/390 [==============================] - 1748s 4s/step - loss: 0.3972 - acc: 0.8683 - val_loss: 0.4325 - val_acc: 0.8588
Epoch 24/30
390/390 [==============================] - 1747s 4s/step - loss: 0.3952 - acc: 0.8693 - val_loss: 0.3984 - val_acc: 0.8765
Epoch 25/30
390/390 [==============================] - 1745s 4s/step - loss: 0.3757 - acc: 0.8756 - val_loss: 0.4028 - val_acc: 0.8751
Epoch 26/30
390/390 [==============================] - 1745s 4s/step - loss: 0.3710 - acc: 0.8782 - val_loss: 0.4182 - val_acc: 0.8664
Epoch 27/30
390/390 [==============================] - 1744s 4s/step - loss: 0.3618 - acc: 0.8805 - val_loss: 0.4620 - val_acc: 0.8596
Epoch 28/30
390/390 [==============================] - 1744s 4s/step - loss: 0.3514 - acc: 0.8834 - val_loss: 0.4346 - val_acc: 0.8647
Epoch 29/30
390/390 [==============================] - 1743s 4s/step - loss: 0.3489 - acc: 0.8850 - val_loss: 0.4305 - val_acc: 0.8691
Epoch 30/30
390/390 [==============================] - 1741s 4s/step - loss: 0.3379 - acc: 0.8889 - val_loss: 0.4078 - val_acc: 0.8732
10000/10000 [==============================] - 54s 5ms/step
test accuracy: 0.8732
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f5161db37b8>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
root@d97b3c148a5b:/srv/keras_compressor/example/cifar10# python3 compress.py
Using TensorFlow backend.
2019-03-01 23:20:22.197342: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:keras_compressor.compressor:factorizer not found layer:<keras.engine.input_layer.InputLayer object at 0x7f1965e241d0>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24240> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
/usr/local/lib/python3.5/dist-packages/keras_compressor/factorizers/tucker.py:97: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
return W[sli]
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24240> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194d572d30>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e247b8>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e24630>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24908> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24908> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194d560a20>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e24828>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.pooling.MaxPooling2D object at 0x7f1965e24a90>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24ba8> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24ba8> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c2288d0>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e24c50>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e24dd8>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24ef0> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e24ef0> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194d560978>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e380f0>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.pooling.MaxPooling2D object at 0x7f1965e38208>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e382b0> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e382b0> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194d5608d0>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e38438>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e38550>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38588> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38588> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c4e2a58>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e38710>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e38828>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38860> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38860> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c20c208>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e389e8>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.pooling.MaxPooling2D object at 0x7f1965e38b00>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38ba8> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38ba8> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c4b6400>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e38d30>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e38e48>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38e80> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e38e80> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c4b6470>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e3c048>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e3c160>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c198> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c198> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c473048>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e3c320>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.pooling.MaxPooling2D object at 0x7f1965e3c438>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c4e0> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c4e0> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c4441d0>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e3c668>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e3c780>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c7b8> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3c7b8> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c4007b8>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e3c940>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e3ca58>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3ca90> factorizer:<class 'keras_compressor.factorizers.tucker.TuckerFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.convolutional.Conv2D object at 0x7f1965e3ca90> new_layer<keras_compressor.layers.FactorizedConv2DTucker object at 0x7f194c423860>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e3cc18>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.pooling.MaxPooling2D object at 0x7f1965e3cd30>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Flatten object at 0x7f1965e3cdd8>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e3ce48>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.core.Dense object at 0x7f1965e3ce80> factorizer:<class 'keras_compressor.factorizers.svd.SVDFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.core.Dense object at 0x7f1965e3ce80> new_layer<keras_compressor.layers.FactorizedDense object at 0x7f194c400390>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.normalization.BatchNormalization object at 0x7f1965e24f28>
INFO:keras_compressor.compressor:factorizer not found layer:<keras.layers.core.Dropout object at 0x7f1965e41128>
INFO:keras_compressor.compressor:factorizer found layer:<keras.layers.core.Dense object at 0x7f1965e41160> factorizer:<class 'keras_compressor.factorizers.svd.SVDFactorizer'>
INFO:keras_compressor.compressor:swap old/new layer old_layer:<keras.layers.core.Dense object at 0x7f1965e41160> new_layer<keras_compressor.layers.FactorizedDense object at 0x7f194c473c88>
root@d97b3c148a5b:/srv/keras_compressor/example/cifar10# python3 finetune.py
Using TensorFlow backend.
2019-03-04 10:28:24.897016: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Train on 50000 samples, validate on 10000 samples
Epoch 1/12
50000/50000 [==============================] - 1173s 23ms/step - loss: 0.4078 - acc: 0.8675 - val_loss: 0.5818 - val_acc: 0.8507
Epoch 2/12
50000/50000 [==============================] - 1145s 23ms/step - loss: 0.3782 - acc: 0.8792 - val_loss: 0.5374 - val_acc: 0.8652
Epoch 3/12
50000/50000 [==============================] - 1147s 23ms/step - loss: 0.3508 - acc: 0.8871 - val_loss: 0.5719 - val_acc: 0.8484
Epoch 4/12
50000/50000 [==============================] - 1248s 25ms/step - loss: 0.3341 - acc: 0.8932 - val_loss: 0.5094 - val_acc: 0.8608
Epoch 5/12
50000/50000 [==============================] - 1202s 24ms/step - loss: 0.3174 - acc: 0.8996 - val_loss: 0.4677 - val_acc: 0.8692
Epoch 6/12
50000/50000 [==============================] - 1176s 24ms/step - loss: 0.2963 - acc: 0.9078 - val_loss: 0.5108 - val_acc: 0.8607
Epoch 7/12
50000/50000 [==============================] - 1144s 23ms/step - loss: 0.2823 - acc: 0.9098 - val_loss: 0.4984 - val_acc: 0.8639
Epoch 8/12
50000/50000 [==============================] - 1240s 25ms/step - loss: 0.2745 - acc: 0.9127 - val_loss: 0.5567 - val_acc: 0.8437
Epoch 9/12
50000/50000 [==============================] - 1198s 24ms/step - loss: 0.2633 - acc: 0.9153 - val_loss: 0.5219 - val_acc: 0.8593
Epoch 10/12
50000/50000 [==============================] - 1143s 23ms/step - loss: 0.2464 - acc: 0.9186 - val_loss: 0.4763 - val_acc: 0.8751
Epoch 11/12
50000/50000 [==============================] - 1131s 23ms/step - loss: 0.2361 - acc: 0.9249 - val_loss: 0.4395 - val_acc: 0.8782
Epoch 12/12
50000/50000 [==============================] - 1132s 23ms/step - loss: 0.2301 - acc: 0.9275 - val_loss: 0.4549 - val_acc: 0.8746
10000/10000 [==============================] - 42s 4ms/step
test accuracy: 0.8746
from keras.models import Model
dense_layer2_name = 'dense_2'
dense_layer2 = model_raw.get_layer(dense_layer2_name)
dense_layer2_wb = dense_layer2.get_weights()
dense_layer2_model = Model(inputs=model_raw.input,
outputs=model_raw.get_layer(dense_layer2_name).output)
dense_layer2_output = dense_layer2_model.predict(x_test, verbose=1)
10000/10000 [==============================] - 5s 491us/step
import numpy as np
dense_layer2_weight = dense_layer2_wb[0]
dense_layer2_bias = dense_layer2_wb[1]
print(dense_layer2_weight.shape)
print(dense_layer2_bias.shape)
print("dense_layer2_weight = {0}".format(dense_layer2_weight))
print("dense_layer2_bias = {0}".format(dense_layer2_bias))
print("np.max(dense_layer2_weight) = {0}".format(np.max(dense_layer2_weight)))
print("np.min(dense_layer2_weight) = {0}".format(np.min(dense_layer2_weight)))
abs_dense_layer2_weight = np.absolute(dense_layer2_weight)
print("np.max(abs_dense_layer2_weight) = {0}".format(np.max(abs_dense_layer2_weight)))
print("np.min(abs_dense_layer2_weight) = {0}".format(np.min(abs_dense_layer2_weight)))
print("np.max(dense_layer2_bias) = {0}".format(np.max(dense_layer2_bias)))
print("np.min(dense_layer2_bias) = {0}".format(np.min(dense_layer2_bias)))
abs_dense_layer2_bias = np.absolute(dense_layer2_bias)
print("np.max(abs_dense_layer2_bias) = {0}".format(np.max(abs_dense_layer2_bias)))
print("np.min(abs_dense_layer2_bias) = {0}".format(np.min(abs_dense_layer2_bias)))
print("dense_layer2_output = {0}".format(dense_layer2_output.shape))
print("np.std(dense_layer2_output) = {0}".format(np.std(dense_layer2_output)))
print("np.max(dense_layer2_output) = {0}".format(np.max(dense_layer2_output)))
print("np.min(dense_layer2_output) = {0}".format(np.min(dense_layer2_output)))
abs_dense_layer2_output = np.absolute(dense_layer2_output)
print("np.max(abs_dense_layer2_output) = {0}".format(np.max(abs_dense_layer2_output)))
print("np.min(abs_dense_layer2_output) = {0}".format(np.min(abs_dense_layer2_output)))
(128, 10)
(10,)
dense_layer2_weight = [[-0.39988974 -0.12601139 -0.46622646 ... -0.44695276 -0.46335962
0.13559648]
[ 0.07339579 -0.45668814 -0.333825 ... -0.7270869 0.17933416
-0.5707154 ]
[ 0.06677974 -0.5544925 0.1668607 ... -0.46047652 -0.4375593
-0.05378945]
...
[-0.05012963 -0.112903 -0.1406179 ... 0.16494776 0.20007576
-0.21182767]
[-0.5350573 -0.40777698 0.19234389 ... 0.19444552 -0.33254635
-0.54401803]
[-0.52111495 -0.26989737 0.20298809 ... 0.08232445 0.14694539
-0.36222363]]
dense_layer2_bias = [ 0.04120593 0.23183034 0.00655218 -0.07728817 -0.09058365 -0.0624351
-0.14979938 -0.04618856 -0.06826726 -0.0130224 ]
np.max(dense_layer2_weight) = 0.39613091945648193
np.min(dense_layer2_weight) = -1.0431485176086426
np.max(abs_dense_layer2_weight) = 1.0431485176086426
np.min(abs_dense_layer2_weight) = 0.0008003973634913564
np.max(dense_layer2_bias) = 0.23183034360408783
np.min(dense_layer2_bias) = -0.1497993767261505
np.max(abs_dense_layer2_bias) = 0.23183034360408783
np.min(abs_dense_layer2_bias) = 0.00655217794701457
dense_layer2_output = (10000, 10)
np.std(dense_layer2_output) = 0.29531362652778625
np.max(dense_layer2_output) = 1.0
np.min(dense_layer2_output) = 3.318871697834195e-19
np.max(abs_dense_layer2_output) = 1.0
np.min(abs_dense_layer2_output) = 3.318871697834195e-19
# Dence layer2のweightのグラフ
dense_layer2_weight_f = dense_layer2_weight.flatten()
plt.plot(dense_layer2_weight_f)
plt.title('dense_layer2_weight')
plt.show()
# Dence layer1のbiasのグラフ
dence_layer1_bias_f = dence_layer1_bias.flatten()
plt.plot(dence_layer1_bias_f)
plt.title('dence_layer1_bias')
plt.show()
# 1番目のdense layer1の中間出力を取り出す
from keras.models import Model
dense_layer1_name = 'dense_1'
dense_layer1 = model_raw.get_layer(dense_layer1_name)
dense_layer1_wb = dense_layer1.get_weights()
dense_layer1_model = Model(inputs=model_raw.input,
outputs=model_raw.get_layer(dense_layer1_name).output)
dense_layer1_output = dense_layer1_model.predict(x_test, verbose=1)
10000/10000 [==============================] - 5s 501us/step
dense_layer1_weight = dense_layer1_wb[0]
dense_layer1_bias = dense_layer1_wb[1]
print(dense_layer1_weight.shape)
print(dense_layer1_weight.T.shape)
print(dense_layer1_bias.shape)
(9216, 128)
(128, 9216)
(128,)
# Dence layer1の中間出力の統計情報の表示
import numpy as np
dence_layer1_weight = dence_layer1_wb[0]
dence_layer1_bias = dence_layer1_wb[1]
print(dence_layer1_weight.shape)
print(dence_layer1_bias.shape)
print("dence_layer1_weight = {0}".format(dence_layer1_weight))
print("dence_layer1_bias = {0}".format(dence_layer1_bias))
print("np.max(dence_layer1_weight) = {0}".format(np.max(dence_layer1_weight)))
print("np.min(dence_layer1_weight) = {0}".format(np.min(dence_layer1_weight)))
abs_dence_layer1_weight = np.absolute(dence_layer1_weight)
print("np.max(abs_dence_layer1_weight) = {0}".format(np.max(abs_dence_layer1_weight)))
print("np.min(abs_dence_layer1_weight) = {0}".format(np.min(abs_dence_layer1_weight)))
print("np.max(dence_layer1_bias) = {0}".format(np.max(dence_layer1_bias)))
print("np.min(dence_layer1_bias) = {0}".format(np.min(dence_layer1_bias)))
abs_dence_layer1_bias = np.absolute(dence_layer1_bias)
print("np.max(abs_dence_layer1_bias) = {0}".format(np.max(abs_dence_layer1_bias)))
print("np.min(abs_dence_layer1_bias) = {0}".format(np.min(abs_dence_layer1_bias)))
print("dence_layer1_output = {0}".format(dence_layer1_output.shape))
print("np.std(dence_layer1_output) = {0}".format(np.std(dence_layer1_output)))
print("np.max(dence_layer1_output) = {0}".format(np.max(dence_layer1_output)))
print("np.min(dence_layer1_output) = {0}".format(np.min(dence_layer1_output)))
abs_dence_layer1_output = np.absolute(dence_layer1_output)
print("np.max(abs_dence_layer1_output) = {0}".format(np.max(abs_dence_layer1_output)))
print("np.min(abs_dence_layer1_output) = {0}".format(np.min(abs_dence_layer1_output)))
(9216, 128)
(128,)
dence_layer1_weight = [[ 0.00470384 -0.01098892 0.0251282 ... -0.02190203 0.01992498
-0.00856046]
[-0.00689279 0.00944513 -0.01233803 ... 0.02524373 -0.02891207
-0.00187604]
[-0.00194416 0.03971022 0.03803337 ... 0.01431566 0.00224361
0.02952734]
...
[ 0.03151323 -0.00314217 -0.00652592 ... -0.02395282 0.0161369
0.02760857]
[-0.04572763 0.05457359 0.00654751 ... -0.00405126 -0.00480561
-0.05019789]
[ 0.01498569 0.0050351 0.04433047 ... -0.00691412 0.03109068
-0.01302621]]
dence_layer1_bias = [-0.06168257 -0.1514682 -0.1322928 -0.10744902 -0.08265022 -0.05077443
-0.06567107 -0.09612435 -0.16938643 -0.08640631 -0.17030963 -0.0943355
-0.00991632 -0.08720349 -0.12731756 -0.07198199 -0.11136244 -0.08368985
-0.13953699 -0.131075 -0.08466823 -0.00631496 -0.17218405 -0.06344838
-0.17180654 -0.14032175 -0.07136092 -0.09621119 -0.00660794 -0.01606259
-0.09382402 -0.04687085 -0.10574532 -0.16411512 -0.01561454 -0.06328947
-0.15161262 -0.08436941 -0.10497447 -0.12699552 -0.12868118 -0.09164497
-0.11735129 -0.17970178 -0.11265838 -0.076789 -0.11856248 -0.06805629
-0.11970215 -0.10988984 -0.01188129 -0.11470675 -0.11072908 -0.0443239
-0.13116506 -0.13980559 -0.11000474 0.00931341 -0.06132468 -0.12936714
-0.11785036 -0.14282347 -0.11910468 -0.16563804 -0.1154892 -0.06983681
-0.09040678 -0.11911937 -0.13075021 -0.07354662 -0.17754656 -0.03138041
-0.10065349 -0.10409548 -0.08683839 -0.09837727 -0.04784932 -0.00906859
-0.01060055 -0.10975196 -0.11331895 -0.14100014 -0.13861252 -0.09429768
-0.1434664 -0.07264388 -0.03577153 -0.00947432 -0.05689292 -0.17511971
-0.00466694 -0.14445004 -0.1057132 -0.0294685 -0.14415818 -0.09408505
-0.05248842 -0.07065452 -0.12279639 -0.04660085 -0.15480113 -0.17639175
-0.0758699 -0.10553791 -0.05692659 -0.08024313 -0.1117903 -0.11112501
-0.04388554 -0.08886621 -0.15003382 -0.09736416 -0.12964201 -0.06801744
-0.08971801 -0.11670808 -0.12153988 -0.00981606 -0.09409956 -0.10864237
-0.13626133 -0.05466016 -0.11123326 -0.07980989 -0.16771536 -0.10403304
-0.1670245 -0.21162453]
np.max(dence_layer1_weight) = 0.5825158953666687
np.min(dence_layer1_weight) = -0.41720789670944214
np.max(abs_dence_layer1_weight) = 0.5825158953666687
np.min(abs_dence_layer1_weight) = 6.024913545843447e-08
np.max(dence_layer1_bias) = 0.00931340642273426
np.min(dence_layer1_bias) = -0.21162453293800354
np.max(abs_dence_layer1_bias) = 0.21162453293800354
np.min(abs_dence_layer1_bias) = 0.004666939377784729
dence_layer1_output = (10000, 128)
np.std(dence_layer1_output) = 0.6154659986495972
np.max(dence_layer1_output) = 4.879707336425781
np.min(dence_layer1_output) = 0.0
np.max(abs_dence_layer1_output) = 4.879707336425781
np.min(abs_dence_layer1_output) = 0.0
# Dence layer1のweightのグラフ
dence_layer1_weight_f = dence_layer1_weight.flatten()
plt.plot(dence_layer1_weight_f)
plt.title('dence_layer1_weight')
plt.show()
# Dence layer1のbiasのグラフ
dence_layer1_bias_f = dence_layer1_bias.flatten()
plt.plot(dence_layer1_bias_f)
plt.title('dence_layer1_bias')
plt.show()
# Convolution layer2 の中間出力を取り出す dense
from keras.models import Modeldense
dense
conv_layer2_name = 'conv2d_2'dense
dense
conv_layer2 = model_raw.get_layer(conv_layer2_name)dense
conv_layer2_wb = conv_layer2.get_weights()dense
dense
conv_layer2_model = Model(inputs=model_raw.input,dense
outputs=model_raw.get_layer(conv_layer2_name).output)dense
conv2_output = conv_layer2_model.predict(x_test, verbose=1)
10000/10000 [==============================] - 8s 765us/step
conv_layer2_weight = conv_layer2_wb[0]
conv_layer2_bias = conv_layer2_wb[1]
print(conv_layer2_weight.shape)
print(conv_layer2_weight.T.shape)
print(conv_layer2_bias.shape)
(3, 3, 32, 64)
(64, 32, 3, 3)
(64,)
print("conv_layer2_weight.T = {0}".format(conv_layer2_weight.T))
conv_layer2_weight.T = [[[[ 0.01784169 -0.22131965 -0.16750205]
[-0.2639166 -0.24390881 -0.1349165 ]
[-0.22022615 -0.13424525 0.03606407]]
[[ 0.00849118 -0.04595165 0.0551733 ]
[-0.13494554 -0.09552263 -0.17330258]
[ 0.0753931 -0.19278674 -0.11913268]]
[[ 0.1441614 0.00560335 -0.03908797]
[ 0.0333319 0.05042576 -0.08194944]
[-0.07048219 0.02250148 -0.0651824 ]]
...
[[ 0.05605402 0.09735671 0.08520151]
[-0.08460605 0.03345596 -0.03969822]
[-0.09354184 -0.11395966 -0.2386213 ]]
[[ 0.07731646 0.10309629 -0.05285215]
[ 0.01115145 0.05118542 -0.03705103]
[-0.08374058 -0.10000117 -0.13344261]]
[[-0.21285664 -0.07637326 -0.11807112]
[-0.0872641 -0.09507918 -0.02423166]
[-0.11540057 -0.08176904 -0.06490589]]]
[[[ 0.07252679 0.06954905 0.12537089]
[-0.03229538 0.03017478 -0.04630463]
[ 0.02097548 -0.02660633 0.00960674]]
[[ 0.12599792 0.10061093 -0.14380467]
[ 0.15743831 0.05114197 -0.2771658 ]
[ 0.0689197 -0.13323346 -0.2662513 ]]
[[ 0.08159676 -0.13551575 -0.3436229 ]
[ 0.03267855 0.06596102 -0.3013157 ]
[-0.03452173 -0.13858531 -0.16072227]]
...
[[-0.03201892 -0.00297785 0.0185745 ]
[-0.00817327 0.09832835 0.06953567]
[ 0.17358212 0.0870876 -0.02251608]]
[[-0.16763942 -0.3161246 -0.14865172]
[-0.12597817 -0.3417036 -0.15690652]
[ 0.04152744 -0.12624545 -0.11262694]]
[[-0.10200371 0.07960378 0.05031039]
[-0.02846055 -0.08170375 0.12832679]
[ 0.09110897 0.03700143 -0.01683243]]]
[[[-0.01097492 0.02248521 0.16480623]
[ 0.02680427 -0.08301172 0.0185292 ]
[-0.11983979 -0.1192525 -0.06802542]]
[[-0.04117574 0.04049781 -0.13980682]
[-0.07642376 0.10412158 0.03532882]
[ 0.07239848 0.07695939 -0.06664034]]
[[ 0.10669465 0.11727943 -0.08763045]
[ 0.05561309 0.03903994 -0.11831472]
[-0.02032233 -0.04828302 0.04822908]]
...
[[-0.06403774 -0.01820614 0.00787074]
[-0.05458642 -0.02513286 -0.03289285]
[-0.14240177 -0.10622517 -0.14554805]]
[[-0.00132929 -0.01552058 -0.0673898 ]
[ 0.06745421 0.02022707 -0.1390137 ]
[-0.00278586 -0.01311766 -0.08565197]]
[[-0.07402381 0.12787989 0.09319225]
[-0.00096143 0.02168931 0.03331943]
[-0.00968612 0.03589568 0.02383618]]]
...
[[[ 0.0018453 -0.13253921 -0.12945914]
[-0.06278129 -0.07392175 -0.14944914]
[-0.11052338 -0.23914535 -0.22029497]]
[[ 0.02723508 -0.05506902 -0.04423543]
[ 0.1670157 0.06717188 0.11392233]
[ 0.01090579 0.00986434 -0.12726213]]
[[-0.07041598 0.04368603 -0.0439879 ]
[ 0.0517549 -0.0583111 -0.03284019]
[-0.01574312 0.01930327 0.09448915]]
...
[[ 0.08875347 0.05630978 -0.00529092]
[-0.0304523 0.04554279 -0.05971542]
[ 0.02514045 0.04610986 0.04479846]]
[[ 0.06760995 -0.05780705 0.0778336 ]
[-0.05120533 -0.00925362 0.1131255 ]
[ 0.1042031 -0.02880889 0.16454437]]
[[-0.06327637 -0.07312059 -0.07421203]
[-0.00637156 -0.10024032 -0.2086502 ]
[-0.01108299 -0.11301193 -0.11094074]]]
[[[-0.14215174 -0.05250412 -0.0090812 ]
[-0.0928833 -0.12365779 0.21822254]
[-0.09645115 -0.28084764 0.16772458]]
[[-0.10625021 0.06715798 0.13000865]
[-0.09430328 -0.00373708 0.08581509]
[-0.3111424 -0.12384682 -0.04418406]]
[[-0.13106433 -0.07839978 -0.18065412]
[-0.06607336 0.08278285 -0.02248873]
[ 0.12788951 0.16163033 0.0536258 ]]
...
[[-0.34901655 -0.10141616 -0.02693314]
[-0.2983937 -0.15410991 0.07247194]
[-0.09468765 -0.1493755 -0.01842348]]
[[-0.11536116 -0.19297424 0.06110919]
[-0.03551681 0.03248382 0.02823978]
[-0.02293781 0.01535376 -0.10231322]]
[[ 0.10867406 0.00733983 -0.02937514]
[ 0.05518444 0.02402998 0.02671161]
[ 0.1154867 0.06526493 0.07580288]]]
[[[ 0.05041484 0.085272 0.08250518]
[-0.0907499 0.0033332 0.09291119]
[-0.12325586 -0.05949372 0.03192182]]
[[ 0.06377354 0.04935758 0.04397005]
[ 0.05296668 0.02406436 0.05589819]
[-0.07718782 -0.13519521 -0.20206876]]
[[-0.08898731 -0.07421607 -0.0766596 ]
[ 0.02380313 0.03121348 0.04296595]
[-0.07588881 -0.11828827 0.09910108]]
...
[[ 0.01745879 -0.05311462 -0.07193764]
[ 0.0888538 -0.04104587 -0.03298815]
[-0.01826777 -0.27299204 -0.1160126 ]]
[[-0.03162678 -0.1756806 -0.03228816]
[ 0.0256981 0.08202723 0.01641914]
[ 0.0224688 -0.08321954 -0.11221529]]
[[ 0.16707096 0.000507 0.04078325]
[-0.05756345 -0.21379665 0.00349825]
[-0.00337872 -0.14029837 -0.04840912]]]]
print("conv_layer_bias = {0}".format(conv_layer2_bias))
conv_layer_bias = [-0.03850411 -0.01573794 0.01115942 0.00562205 -0.03604732 0.01286564
-0.09528935 -0.04337158 -0.01698404 -0.05879769 -0.03624293 -0.08855402
-0.04848624 -0.03195901 -0.08869974 0.00507461 -0.07211261 -0.05120531
-0.07258753 -0.02589275 0.00240357 -0.03014836 -0.07204135 -0.01561245
-0.03739467 -0.04205899 -0.06722149 0.00948338 -0.03016038 -0.02061644
-0.05402645 0.14428563 -0.05207796 -0.05976514 -0.04870901 0.00583873
-0.00821861 -0.0367915 -0.04091152 -0.0452308 0.01322065 -0.0670034
-0.03599038 -0.06793729 -0.07481442 -0.06112335 -0.00378744 -0.06627614
-0.07054048 0.02497522 -0.03339541 -0.02779962 -0.06606241 -0.0774965
-0.02701756 -0.02294137 -0.06889407 -0.03851727 -0.01658753 0.01253654
-0.06667125 -0.0335856 0.00278443 -0.04023726]
import numpy as np
print("np.max(conv_layer2_weight) = {0}".format(np.max(conv_layer2_weight)))
print("np.min(conv_layer2_weight) = {0}".format(np.min(conv_layer2_weight)))
abs_conv_layer2_weight = np.absolute(conv_layer2_weight)
print("np.max(abs_conv_layer2_weight) = {0}".format(np.max(abs_conv_layer2_weight)))
print("np.min(abs_conv_layer2_weight) = {0}".format(np.min(abs_conv_layer2_weight)))
print("np.max(conv_layer2_bias) = {0}".format(np.max(conv_layer2_bias)))
print("np.min(conv_layer2_bias) = {0}".format(np.min(conv_layer2_bias)))
abs_conv_layer2_bias = np.absolute(conv_layer2_bias)
print("np.max(abs_conv_layer2_bias) = {0}".format(np.max(abs_conv_layer2_bias)))
print("np.min(abs_conv_layer2_bias) = {0}".format(np.min(abs_conv_layer2_bias)))
print("conv2_output = {0}".format(conv2_output.shape))
print("np.std(conv2_output) = {0}".format(np.std(conv2_output)))
print("np.max(conv2_output) = {0}".format(np.max(conv2_output)))
print("np.min(conv2_output) = {0}".format(np.min(conv2_output)))
abs_conv2_output = np.absolute(conv2_output)
print("np.max(abs_conv) = {0}".format(np.max(abs_conv2_output)))
print("np.min(abs_conv) = {0}".format(np.min(abs_conv2_output)))
np.max(conv_layer2_weight) = 0.411957323551178
np.min(conv_layer2_weight) = -0.45342838764190674
np.max(abs_conv_layer2_weight) = 0.45342838764190674
np.min(abs_conv_layer2_weight) = 3.3898611491167685e-06
np.max(conv_layer2_bias) = 0.1442856341600418
np.min(conv_layer2_bias) = -0.09528934955596924
np.max(abs_conv_layer2_bias) = 0.1442856341600418
np.min(abs_conv_layer2_bias) = 0.002403571968898177
conv2_output = (10000, 24, 24, 64)
np.std(conv2_output) = 0.07447987049818039
np.max(conv2_output) = 2.7997069358825684
np.min(conv2_output) = 0.0
np.max(abs_conv) = 2.7997069358825684
np.min(abs_conv) = 0.0
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
# Convolution layer2のweightのグラフ
conv_layer2_weight_f = conv_layer2_weight.flatten()
plt.plot(conv_layer2_weight_f)
plt.title('conv_layer2_weight')
plt.show()
# Convolution layer2のbiasのグラフ
conv_layer2_bias_f = conv_layer2_bias.flatten()
plt.plot(conv_layer2_bias_f)
plt.title('conv_layer2_bias')
plt.show()
# DwangoMediaVillage/keras_compressor/example/mnist/train.py から一部引用
# https://github.com/DwangoMediaVillage/keras_compressor/blob/master/example/mnist/train.py
from keras import backend as K
from keras.callbacks import EarlyStopping
from keras.datasets import mnist
from keras.layers import Conv2D, Dense, Dropout, Flatten, Input, MaxPool2D
from keras.models import Model
from keras.utils.np_utils import to_categorical
def gen_model():
# from keras mnist tutorial
img_input = Input(shape=(img_rows, img_cols, 1))
h = img_input
h = Conv2D(32, (3, 3), activation='relu')(h)
h = Dropout(0.25)(h)
h = Conv2D(64, (3, 3), activation='relu')(h)
h = MaxPool2D((2, 2))(h)
h = Dropout(0.25)(h)
h = Flatten()(h)
h = Dense(128, activation='relu')(h)
h = Dropout(0.5)(h)
h = Dense(class_num, activation='softmax')(h)
model = Model(img_input, h)
return model
# 学習済みモデルの読み込み
from keras.models import load_model
import sys, os
sys.path.append("keras_compressor/keras_compressor")
from layers import custom_layers
model_compressed = load_model('model_compressed.h5', custom_layers)
# My Mnist CNN(重みとバイアスの再ロード用モジュール)
# Conv2D - ReLU - MaxPooling - Dence - ReLU - Dence
# 2018/05/25 by marsee
# Keras / Tensorflowで始めるディープラーニング入門 https://qiita.com/yampy/items/706d44417c433e68db0d
# のPythonコードを再利用させて頂いている
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
batch_size = 128
num_classes = 10
epochs = 12
img_rows, img_cols = 28, 28
(x_train, y_train), (x_test, y_test) = mnist.load_data()
#Kerasのバックエンドで動くTensorFlowとTheanoでは入力チャンネルの順番が違うので場合分けして書いています
if K.image_data_format() == 'channels_first':
x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
input_shape = (1, img_rows, img_cols)
else:
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1)
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /=
x_test /=
model_raw_list = model_raw.get_weights()
print(model_raw_list)
[array([[[[-0.05172705, -0.15345924, 0.00077587, -0.03371203,
-0.16821936, 0.12922178, -0.13418826, -0.10867919,
-0.1458925 , 0.19463108, -0.14580294, -0.03869295,
0.10389572, 0.17042054, 0.0100111 , 0.12097651,
-0.4023658 , -0.20207658, -0.07195384, 0.03934375,
-0.11012892, -0.07478225, 0.1226447 , 0.19403256,
0.01812533, -0.05677873, 0.17626294, -0.03892957,
-0.00537937, -0.05291621, -0.16475417, -0.00706133]],
[[ 0.13856724, -0.15383671, -0.08084076, -0.13828416,
-0.07712211, 0.04172476, -0.16041471, -0.08714657,
-0.17163298, -0.03662995, -0.0620219 , 0.10431749,
-0.12399048, -0.00673226, -0.03650982, -0.0106194 ,
-0.18041939, -0.15767479, -0.11838219, 0.10532779,
0.03665911, 0.02992007, 0.00675609, 0.03340556,
0.05760363, 0.0406777 , -0.05025062, 0.03133169,
0.09469289, 0.19778591, 0.04521935, 0.11820332]],
[[-0.01835519, 0.10497978, -0.08119331, -0.04822454,
0.1015288 , -0.05404653, -0.20264348, 0.01448757,
0.05472392, 0.18080442, 0.08911949, 0.15507902,
-0.14813055, 0.03455162, -0.16724327, -0.13468543,
-0.08864182, -0.02936704, 0.01190247, 0.11374157,
0.13765548, -0.06801588, -0.16707923, -0.05098806,
0.16587973, -0.1300925 , 0.07113007, -0.17776224,
0.14063434, 0.18423977, -0.14625272, 0.17271286]]],
[[[-0.05083156, -0.13264939, 0.04466102, 0.03564763,
0.03559402, 0.13187517, 0.03594281, 0.05526815,
-0.11275288, 0.0039167 , -0.07657869, -0.03868581,
0.12851602, 0.1521333 , 0.0513791 , -0.12931691,
-0.09383278, -0.1648976 , 0.07744151, -0.07568712,
-0.05860967, -0.05193807, 0.12811543, -0.0282612 ,
0.07773264, 0.06226772, 0.02389823, 0.00214993,
-0.12375973, -0.00676751, -0.02455793, -0.03462191]],
[[-0.03594301, 0.11407857, 0.14229886, 0.04625476,
0.05015176, -0.05551488, -0.02045105, -0.03296088,
0.09474239, -0.06525583, -0.01278242, 0.02829993,
-0.07840222, 0.04641729, -0.03488041, 0.05656511,
0.13930908, -0.03737781, -0.09818485, -0.09107177,
0.07095284, 0.06994601, 0.06080497, -0.13724516,
-0.03498914, -0.11904315, 0.14269935, -0.04210183,
0.0651255 , 0.10612902, 0.11397902, -0.03795255]],
[[ 0.17533973, 0.05431411, -0.08569562, 0.10862813,
-0.06807359, -0.17448065, -0.0100623 , 0.10232493,
0.0435214 , 0.01783775, 0.02181555, 0.12274784,
-0.05855373, -0.05113681, 0.03346287, 0.1236548 ,
0.07271655, 0.11179519, 0.01439611, -0.011888 ,
-0.02642842, -0.1024743 , 0.00944871, -0.01964488,
-0.02744397, -0.11693428, 0.05274292, -0.03606737,
0.09729386, -0.12262847, -0.07408664, -0.07936568]]],
[[[-0.2106485 , -0.07639346, -0.10960838, 0.1468544 ,
0.02582365, 0.10072139, 0.12636843, 0.10368153,
-0.01542548, 0.00699573, 0.04627146, -0.01649213,
0.13230959, -0.08335535, 0.05959431, -0.11145467,
-0.07102275, -0.1388285 , 0.05205231, -0.09978414,
-0.03917275, 0.10191721, -0.10038435, -0.12760422,
-0.2619083 , 0.10844929, -0.13908163, 0.03273428,
0.02183258, 0.00879611, 0.27741808, -0.1739349 ]],
[[-0.19153525, -0.07415977, 0.1546851 , -0.0031653 ,
0.07678907, 0.05759468, 0.0014401 , 0.04860839,
0.1039779 , -0.21813264, 0.07777672, -0.1257387 ,
0.05847128, -0.09520132, 0.02177527, 0.00469245,
0.06917801, -0.04790248, 0.11820323, 0.06097089,
0.07881823, 0.14582054, -0.04223583, -0.17602372,
-0.11885098, 0.0220329 , -0.006604 , 0.04856543,
-0.02801645, -0.01229255, 0.02585949, -0.18842506]],
[[-0.07175326, 0.12322589, 0.00127919, 0.00317867,
-0.09002248, -0.1933257 , 0.1461138 , -0.01340641,
0.09414906, -0.1098635 , 0.05602227, -0.08832221,
-0.00852111, 0.11656286, 0.15776785, 0.15097694,
0.20661522, 0.02434064, -0.03323808, 0.0474364 ,
-0.07273006, 0.03282277, 0.05005337, 0.03691453,
-0.24776074, 0.13606238, -0.19123326, 0.13436365,
-0.02396554, -0.22014052, -0.09753748, -0.02009463]]]],
dtype=float32), array([ 0.03587808, -0.0171744 , 0.00955198, 0.01177248, 0.00439308,
0.0267545 , 0.06779006, -0.02031287, 0.00851296, 0.08016433,
-0.00722928, 0.00845261, 0.04088434, -0.00948897, -0.03233781,
-0.04233009, 0.02995742, 0.03874496, 0.01290099, -0.0231648 ,
-0.03201413, -0.01488906, 0.01443897, 0.02196893, 0.07889408,
0.02526813, 0.01673093, -0.01149702, -0.04930302, -0.01055223,
0.05971717, 0.07986403], dtype=float32), array([[[[ 0.01784169, 0.07252679, -0.01097492, ..., 0.0018453 ,
-0.14215174, 0.05041484],
[ 0.00849118, 0.12599792, -0.04117574, ..., 0.02723508,
-0.10625021, 0.06377354],
[ 0.1441614 , 0.08159676, 0.10669465, ..., -0.07041598,
-0.13106433, -0.08898731],
...,
[ 0.05605402, -0.03201892, -0.06403774, ..., 0.08875347,
-0.34901655, 0.01745879],
[ 0.07731646, -0.16763942, -0.00132929, ..., 0.06760995,
-0.11536116, -0.03162678],
[-0.21285664, -0.10200371, -0.07402381, ..., -0.06327637,
0.10867406, 0.16707096]],
[[-0.2639166 , -0.03229538, 0.02680427, ..., -0.06278129,
-0.0928833 , -0.0907499 ],
[-0.13494554, 0.15743831, -0.07642376, ..., 0.1670157 ,
-0.09430328, 0.05296668],
[ 0.0333319 , 0.03267855, 0.05561309, ..., 0.0517549 ,
-0.06607336, 0.02380313],
...,
[-0.08460605, -0.00817327, -0.05458642, ..., -0.0304523 ,
-0.2983937 , 0.0888538 ],
[ 0.01115145, -0.12597817, 0.06745421, ..., -0.05120533,
-0.03551681, 0.0256981 ],
[-0.0872641 , -0.02846055, -0.00096143, ..., -0.00637156,
0.05518444, -0.05756345]],
[[-0.22022615, 0.02097548, -0.11983979, ..., -0.11052338,
-0.09645115, -0.12325586],
[ 0.0753931 , 0.0689197 , 0.07239848, ..., 0.01090579,
-0.3111424 , -0.07718782],
[-0.07048219, -0.03452173, -0.02032233, ..., -0.01574312,
0.12788951, -0.07588881],
...,
[-0.09354184, 0.17358212, -0.14240177, ..., 0.02514045,
-0.09468765, -0.01826777],
[-0.08374058, 0.04152744, -0.00278586, ..., 0.1042031 ,
-0.02293781, 0.0224688 ],
[-0.11540057, 0.09110897, -0.00968612, ..., -0.01108299,
0.1154867 , -0.00337872]]],
[[[-0.22131965, 0.06954905, 0.02248521, ..., -0.13253921,
-0.05250412, 0.085272 ],
[-0.04595165, 0.10061093, 0.04049781, ..., -0.05506902,
0.06715798, 0.04935758],
[ 0.00560335, -0.13551575, 0.11727943, ..., 0.04368603,
-0.07839978, -0.07421607],
...,
[ 0.09735671, -0.00297785, -0.01820614, ..., 0.05630978,
-0.10141616, -0.05311462],
[ 0.10309629, -0.3161246 , -0.01552058, ..., -0.05780705,
-0.19297424, -0.1756806 ],
[-0.07637326, 0.07960378, 0.12787989, ..., -0.07312059,
0.00733983, 0.000507 ]],
[[-0.24390881, 0.03017478, -0.08301172, ..., -0.07392175,
-0.12365779, 0.0033332 ],
[-0.09552263, 0.05114197, 0.10412158, ..., 0.06717188,
-0.00373708, 0.02406436],
[ 0.05042576, 0.06596102, 0.03903994, ..., -0.0583111 ,
0.08278285, 0.03121348],
...,
[ 0.03345596, 0.09832835, -0.02513286, ..., 0.04554279,
-0.15410991, -0.04104587],
[ 0.05118542, -0.3417036 , 0.02022707, ..., -0.00925362,
0.03248382, 0.08202723],
[-0.09507918, -0.08170375, 0.02168931, ..., -0.10024032,
0.02402998, -0.21379665]],
[[-0.13424525, -0.02660633, -0.1192525 , ..., -0.23914535,
-0.28084764, -0.05949372],
[-0.19278674, -0.13323346, 0.07695939, ..., 0.00986434,
-0.12384682, -0.13519521],
[ 0.02250148, -0.13858531, -0.04828302, ..., 0.01930327,
0.16163033, -0.11828827],
...,
[-0.11395966, 0.0870876 , -0.10622517, ..., 0.04610986,
-0.1493755 , -0.27299204],
[-0.10000117, -0.12624545, -0.01311766, ..., -0.02880889,
0.01535376, -0.08321954],
[-0.08176904, 0.03700143, 0.03589568, ..., -0.11301193,
0.06526493, -0.14029837]]],
[[[-0.16750205, 0.12537089, 0.16480623, ..., -0.12945914,
-0.0090812 , 0.08250518],
[ 0.0551733 , -0.14380467, -0.13980682, ..., -0.04423543,
0.13000865, 0.04397005],
[-0.03908797, -0.3436229 , -0.08763045, ..., -0.0439879 ,
-0.18065412, -0.0766596 ],
...,
[ 0.08520151, 0.0185745 , 0.00787074, ..., -0.00529092,
-0.02693314, -0.07193764],
[-0.05285215, -0.14865172, -0.0673898 , ..., 0.0778336 ,
0.06110919, -0.03228816],
[-0.11807112, 0.05031039, 0.09319225, ..., -0.07421203,
-0.02937514, 0.04078325]],
[[-0.1349165 , -0.04630463, 0.0185292 , ..., -0.14944914,
0.21822254, 0.09291119],
[-0.17330258, -0.2771658 , 0.03532882, ..., 0.11392233,
0.08581509, 0.05589819],
[-0.08194944, -0.3013157 , -0.11831472, ..., -0.03284019,
-0.02248873, 0.04296595],
...,
[-0.03969822, 0.06953567, -0.03289285, ..., -0.05971542,
0.07247194, -0.03298815],
[-0.03705103, -0.15690652, -0.1390137 , ..., 0.1131255 ,
0.02823978, 0.01641914],
[-0.02423166, 0.12832679, 0.03331943, ..., -0.2086502 ,
0.02671161, 0.00349825]],
[[ 0.03606407, 0.00960674, -0.06802542, ..., -0.22029497,
0.16772458, 0.03192182],
[-0.11913268, -0.2662513 , -0.06664034, ..., -0.12726213,
-0.04418406, -0.20206876],
[-0.0651824 , -0.16072227, 0.04822908, ..., 0.09448915,
0.0536258 , 0.09910108],
...,
[-0.2386213 , -0.02251608, -0.14554805, ..., 0.04479846,
-0.01842348, -0.1160126 ],
[-0.13344261, -0.11262694, -0.08565197, ..., 0.16454437,
-0.10231322, -0.11221529],
[-0.06490589, -0.01683243, 0.02383618, ..., -0.11094074,
0.07580288, -0.04840912]]]], dtype=float32), array([-0.03850411, -0.01573794, 0.01115942, 0.00562205, -0.03604732,
0.01286564, -0.09528935, -0.04337158, -0.01698404, -0.05879769,
-0.03624293, -0.08855402, -0.04848624, -0.03195901, -0.08869974,
0.00507461, -0.07211261, -0.05120531, -0.07258753, -0.02589275,
0.00240357, -0.03014836, -0.07204135, -0.01561245, -0.03739467,
-0.04205899, -0.06722149, 0.00948338, -0.03016038, -0.02061644,
-0.05402645, 0.14428563, -0.05207796, -0.05976514, -0.04870901,
0.00583873, -0.00821861, -0.0367915 , -0.04091152, -0.0452308 ,
0.01322065, -0.0670034 , -0.03599038, -0.06793729, -0.07481442,
-0.06112335, -0.00378744, -0.06627614, -0.07054048, 0.02497522,
-0.03339541, -0.02779962, -0.06606241, -0.0774965 , -0.02701756,
-0.02294137, -0.06889407, -0.03851727, -0.01658753, 0.01253654,
-0.06667125, -0.0335856 , 0.00278443, -0.04023726], dtype=float32), array([[ 0.00470384, -0.01098892, 0.0251282 , ..., -0.02190203,
0.01992498, -0.00856046],
[-0.00689279, 0.00944513, -0.01233803, ..., 0.02524373,
-0.02891207, -0.00187604],
[-0.00194416, 0.03971022, 0.03803337, ..., 0.01431566,
0.00224361, 0.02952734],
...,
[ 0.03151323, -0.00314217, -0.00652592, ..., -0.02395282,
0.0161369 , 0.02760857],
[-0.04572763, 0.05457359, 0.00654751, ..., -0.00405126,
-0.00480561, -0.05019789],
[ 0.01498569, 0.0050351 , 0.04433047, ..., -0.00691412,
0.03109068, -0.01302621]], dtype=float32), array([-0.06168257, -0.1514682 , -0.1322928 , -0.10744902, -0.08265022,
-0.05077443, -0.06567107, -0.09612435, -0.16938643, -0.08640631,
-0.17030963, -0.0943355 , -0.00991632, -0.08720349, -0.12731756,
-0.07198199, -0.11136244, -0.08368985, -0.13953699, -0.131075 ,
-0.08466823, -0.00631496, -0.17218405, -0.06344838, -0.17180654,
-0.14032175, -0.07136092, -0.09621119, -0.00660794, -0.01606259,
-0.09382402, -0.04687085, -0.10574532, -0.16411512, -0.01561454,
-0.06328947, -0.15161262, -0.08436941, -0.10497447, -0.12699552,
-0.12868118, -0.09164497, -0.11735129, -0.17970178, -0.11265838,
-0.076789 , -0.11856248, -0.06805629, -0.11970215, -0.10988984,
-0.01188129, -0.11470675, -0.11072908, -0.0443239 , -0.13116506,
-0.13980559, -0.11000474, 0.00931341, -0.06132468, -0.12936714,
-0.11785036, -0.14282347, -0.11910468, -0.16563804, -0.1154892 ,
-0.06983681, -0.09040678, -0.11911937, -0.13075021, -0.07354662,
-0.17754656, -0.03138041, -0.10065349, -0.10409548, -0.08683839,
-0.09837727, -0.04784932, -0.00906859, -0.01060055, -0.10975196,
-0.11331895, -0.14100014, -0.13861252, -0.09429768, -0.1434664 ,
-0.07264388, -0.03577153, -0.00947432, -0.05689292, -0.17511971,
-0.00466694, -0.14445004, -0.1057132 , -0.0294685 , -0.14415818,
-0.09408505, -0.05248842, -0.07065452, -0.12279639, -0.04660085,
-0.15480113, -0.17639175, -0.0758699 , -0.10553791, -0.05692659,
-0.08024313, -0.1117903 , -0.11112501, -0.04388554, -0.08886621,
-0.15003382, -0.09736416, -0.12964201, -0.06801744, -0.08971801,
-0.11670808, -0.12153988, -0.00981606, -0.09409956, -0.10864237,
-0.13626133, -0.05466016, -0.11123326, -0.07980989, -0.16771536,
-0.10403304, -0.1670245 , -0.21162453], dtype=float32), array([[-0.39988974, -0.12601139, -0.46622646, ..., -0.44695276,
-0.46335962, 0.13559648],
[ 0.07339579, -0.45668814, -0.333825 , ..., -0.7270869 ,
0.17933416, -0.5707154 ],
[ 0.06677974, -0.5544925 , 0.1668607 , ..., -0.46047652,
-0.4375593 , -0.05378945],
...,
[-0.05012963, -0.112903 , -0.1406179 , ..., 0.16494776,
0.20007576, -0.21182767],
[-0.5350573 , -0.40777698, 0.19234389, ..., 0.19444552,
-0.33254635, -0.54401803],
[-0.52111495, -0.26989737, 0.20298809, ..., 0.08232445,
0.14694539, -0.36222363]], dtype=float32), array([ 0.04120593, 0.23183034, 0.00655218, -0.07728817, -0.09058365,
-0.0624351 , -0.14979938, -0.04618856, -0.06826726, -0.0130224 ],
dtype=float32)]
model_raw.summary()
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 28, 28, 1) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 26, 26, 32) 320
_________________________________________________________________
dropout_1 (Dropout) (None, 26, 26, 32) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 24, 24, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 64) 0
_________________________________________________________________
dropout_2 (Dropout) (None, 12, 12, 64) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 9216) 0
_________________________________________________________________
dense_1 (Dense) (None, 128) 1179776
_________________________________________________________________
dropout_3 (Dropout) (None, 128) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 1290
=================================================================
Total params: 1,199,882
Trainable params: 1,199,882
Non-trainable params: 0
_________________________________________________________________
# Convolution layerの中間出力を取り出す
from keras.models import Model
conv_layer_name = 'conv2d_1'
conv_layer = model_raw.get_layer(conv_layer_name)
conv_layer_wb = conv_layer.get_weights()
conv_layer_model = Model(inputs=model_raw.input,
outputs=model_raw.get_layer(conv_layer_name).output)
conv_output = conv_layer_model.predict(x_test, verbose=1)
10000/10000 [==============================] - 2s 227us/step
conv_layer_weight = conv_layer_wb[0]
conv_layer_bias = conv_layer_wb[1]
print(conv_layer_weight.shape)
print(conv_layer_weight.T.shape)
print(conv_layer_bias.shape)
(3, 3, 1, 32)
(32, 1, 3, 3)
(32,)
print("conv_layer_weight.T = {0}".format(conv_layer_weight.T))
conv_layer_weight.T = [[[[-0.05172705 -0.05083156 -0.2106485 ]
[ 0.13856724 -0.03594301 -0.19153525]
[-0.01835519 0.17533973 -0.07175326]]]
[[[-0.15345924 -0.13264939 -0.07639346]
[-0.15383671 0.11407857 -0.07415977]
[ 0.10497978 0.05431411 0.12322589]]]
[[[ 0.00077587 0.04466102 -0.10960838]
[-0.08084076 0.14229886 0.1546851 ]
[-0.08119331 -0.08569562 0.00127919]]]
[[[-0.03371203 0.03564763 0.1468544 ]
[-0.13828416 0.04625476 -0.0031653 ]
[-0.04822454 0.10862813 0.00317867]]]
[[[-0.16821936 0.03559402 0.02582365]
[-0.07712211 0.05015176 0.07678907]
[ 0.1015288 -0.06807359 -0.09002248]]]
[[[ 0.12922178 0.13187517 0.10072139]
[ 0.04172476 -0.05551488 0.05759468]
[-0.05404653 -0.17448065 -0.1933257 ]]]
[[[-0.13418826 0.03594281 0.12636843]
[-0.16041471 -0.02045105 0.0014401 ]
[-0.20264348 -0.0100623 0.1461138 ]]]
[[[-0.10867919 0.05526815 0.10368153]
[-0.08714657 -0.03296088 0.04860839]
[ 0.01448757 0.10232493 -0.01340641]]]
[[[-0.1458925 -0.11275288 -0.01542548]
[-0.17163298 0.09474239 0.1039779 ]
[ 0.05472392 0.0435214 0.09414906]]]
[[[ 0.19463108 0.0039167 0.00699573]
[-0.03662995 -0.06525583 -0.21813264]
[ 0.18080442 0.01783775 -0.1098635 ]]]
[[[-0.14580294 -0.07657869 0.04627146]
[-0.0620219 -0.01278242 0.07777672]
[ 0.08911949 0.02181555 0.05602227]]]
[[[-0.03869295 -0.03868581 -0.01649213]
[ 0.10431749 0.02829993 -0.1257387 ]
[ 0.15507902 0.12274784 -0.08832221]]]
[[[ 0.10389572 0.12851602 0.13230959]
[-0.12399048 -0.07840222 0.05847128]
[-0.14813055 -0.05855373 -0.00852111]]]
[[[ 0.17042054 0.1521333 -0.08335535]
[-0.00673226 0.04641729 -0.09520132]
[ 0.03455162 -0.05113681 0.11656286]]]
[[[ 0.0100111 0.0513791 0.05959431]
[-0.03650982 -0.03488041 0.02177527]
[-0.16724327 0.03346287 0.15776785]]]
[[[ 0.12097651 -0.12931691 -0.11145467]
[-0.0106194 0.05656511 0.00469245]
[-0.13468543 0.1236548 0.15097694]]]
[[[-0.4023658 -0.09383278 -0.07102275]
[-0.18041939 0.13930908 0.06917801]
[-0.08864182 0.07271655 0.20661522]]]
[[[-0.20207658 -0.1648976 -0.1388285 ]
[-0.15767479 -0.03737781 -0.04790248]
[-0.02936704 0.11179519 0.02434064]]]
[[[-0.07195384 0.07744151 0.05205231]
[-0.11838219 -0.09818485 0.11820323]
[ 0.01190247 0.01439611 -0.03323808]]]
[[[ 0.03934375 -0.07568712 -0.09978414]
[ 0.10532779 -0.09107177 0.06097089]
[ 0.11374157 -0.011888 0.0474364 ]]]
[[[-0.11012892 -0.05860967 -0.03917275]
[ 0.03665911 0.07095284 0.07881823]
[ 0.13765548 -0.02642842 -0.07273006]]]
[[[-0.07478225 -0.05193807 0.10191721]
[ 0.02992007 0.06994601 0.14582054]
[-0.06801588 -0.1024743 0.03282277]]]
[[[ 0.1226447 0.12811543 -0.10038435]
[ 0.00675609 0.06080497 -0.04223583]
[-0.16707923 0.00944871 0.05005337]]]
[[[ 0.19403256 -0.0282612 -0.12760422]
[ 0.03340556 -0.13724516 -0.17602372]
[-0.05098806 -0.01964488 0.03691453]]]
[[[ 0.01812533 0.07773264 -0.2619083 ]
[ 0.05760363 -0.03498914 -0.11885098]
[ 0.16587973 -0.02744397 -0.24776074]]]
[[[-0.05677873 0.06226772 0.10844929]
[ 0.0406777 -0.11904315 0.0220329 ]
[-0.1300925 -0.11693428 0.13606238]]]
[[[ 0.17626294 0.02389823 -0.13908163]
[-0.05025062 0.14269935 -0.006604 ]
[ 0.07113007 0.05274292 -0.19123326]]]
[[[-0.03892957 0.00214993 0.03273428]
[ 0.03133169 -0.04210183 0.04856543]
[-0.17776224 -0.03606737 0.13436365]]]
[[[-0.00537937 -0.12375973 0.02183258]
[ 0.09469289 0.0651255 -0.02801645]
[ 0.14063434 0.09729386 -0.02396554]]]
[[[-0.05291621 -0.00676751 0.00879611]
[ 0.19778591 0.10612902 -0.01229255]
[ 0.18423977 -0.12262847 -0.22014052]]]
[[[-0.16475417 -0.02455793 0.27741808]
[ 0.04521935 0.11397902 0.02585949]
[-0.14625272 -0.07408664 -0.09753748]]]
[[[-0.00706133 -0.03462191 -0.1739349 ]
[ 0.11820332 -0.03795255 -0.18842506]
[ 0.17271286 -0.07936568 -0.02009463]]]]
print("conv_layer_bias = {0}".format(conv_layer_bias))
conv_layer_bias = [ 0.03587808 -0.0171744 0.00955198 0.01177248 0.00439308 0.0267545
0.06779006 -0.02031287 0.00851296 0.08016433 -0.00722928 0.00845261
0.04088434 -0.00948897 -0.03233781 -0.04233009 0.02995742 0.03874496
0.01290099 -0.0231648 -0.03201413 -0.01488906 0.01443897 0.02196893
0.07889408 0.02526813 0.01673093 -0.01149702 -0.04930302 -0.01055223
0.05971717 0.07986403]
import numpy as np
print("np.max(conv_layer_weight) = {0}".format(np.max(conv_layer_weight)))
print("np.min(conv_layer_weight) = {0}".format(np.min(conv_layer_weight)))
abs_conv_layer_weight = np.absolute(conv_layer_weight)
print("np.max(abs_conv_layer_weight) = {0}".format(np.max(abs_conv_layer_weight)))
print("np.min(abs_conv_layer_weight) = {0}".format(np.min(abs_conv_layer_weight)))
print("np.max(conv_layer_bias) = {0}".format(np.max(conv_layer_bias)))
print("np.min(conv_layer_bias) = {0}".format(np.min(conv_layer_bias)))
abs_conv_layer_bias = np.absolute(conv_layer_bias)
print("np.max(abs_conv_layer_bias) = {0}".format(np.max(abs_conv_layer_bias)))
print("np.min(abs_conv_layer_bias) = {0}".format(np.min(abs_conv_layer_bias)))
print("conv_output = {0}".format(conv_output.shape))
print("np.std(conv_output) = {0}".format(np.std(conv_output)))
print("np.max(conv_output) = {0}".format(np.max(conv_output)))
print("np.min(conv_output) = {0}".format(np.min(conv_output)))
abs_conv_output = np.absolute(conv_output)
print("np.max(abs_conv) = {0}".format(np.max(abs_conv_output)))
print("np.min(abs_conv) = {0}".format(np.min(abs_conv_output)))
np.max(conv_layer_weight) = 0.2774180769920349
np.min(conv_layer_weight) = -0.4023658037185669
np.max(abs_conv_layer_weight) = 0.4023658037185669
np.min(abs_conv_layer_weight) = 0.0007758717983961105
np.max(conv_layer_bias) = 0.08016432821750641
np.min(conv_layer_bias) = -0.04930301755666733
np.max(abs_conv_layer_bias) = 0.08016432821750641
np.min(abs_conv_layer_bias) = 0.0043930779211223125
conv_output = (10000, 26, 26, 32)
np.std(conv_output) = 0.05693778768181801
np.max(conv_output) = 0.5177762508392334
np.min(conv_output) = 0.0
np.max(abs_conv) = 0.5177762508392334
np.min(abs_conv) = 0.0
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
# Convolution layerのweightのグラフ
conv_layer_weight_f = conv_layer_weight.flatten()
plt.plot(conv_layer_weight_f)
plt.title('conv_layer_weight')
plt.show()
# Convolution layerのbiasのグラフ
conv_layer_bias_f = conv_layer_bias.flatten()
plt.plot(conv_layer_bias_f)
plt.title('conv_layer_bias')
plt.show()
root@7552a77f8bdb:/srv/keras_compressor/example/mnist# python3 evaluate.py model_raw.h5
Using TensorFlow backend.
2019-02-27 11:09:05.645341: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 28, 28, 1) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 26, 26, 32) 320
_________________________________________________________________
dropout_1 (Dropout) (None, 26, 26, 32) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 24, 24, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 64) 0
_________________________________________________________________
dropout_2 (Dropout) (None, 12, 12, 64) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 9216) 0
_________________________________________________________________
dense_1 (Dense) (None, 128) 1179776
_________________________________________________________________
dropout_3 (Dropout) (None, 128) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 1290
=================================================================
Total params: 1,199,882
Trainable params: 1,199,882
Non-trainable params: 0
_________________________________________________________________
[0.03550462917517871, 0.9909]
root@7552a77f8bdb:/srv/keras_compressor/example/mnist# python3 evaluate.py model_compressed.h5
Using TensorFlow backend.
2019-02-27 11:10:22.770433: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 28, 28, 1) 0
_________________________________________________________________
conv2d_1 (FactorizedConv2DTu (None, 26, 26, 32) 114
_________________________________________________________________
dropout_1 (Dropout) (None, 26, 26, 32) 0
_________________________________________________________________
conv2d_2 (FactorizedConv2DTu (None, 24, 24, 64) 1939
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 64) 0
_________________________________________________________________
dropout_2 (Dropout) (None, 12, 12, 64) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 9216) 0
_________________________________________________________________
dense_1 (FactorizedDense) (None, 128) 37504
_________________________________________________________________
dropout_3 (Dropout) (None, 128) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 1290
=================================================================
Total params: 40,847
Trainable params: 40,847
Non-trainable params: 0
_________________________________________________________________
[3.8010931224822997, 0.5504]
root@7552a77f8bdb:/srv/keras_compressor/example/mnist# python3 evaluate.py model_finetuned.h5
Using TensorFlow backend.
2019-02-27 11:13:32.563043: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 28, 28, 1) 0
_________________________________________________________________
conv2d_1 (FactorizedConv2DTu (None, 26, 26, 32) 114
_________________________________________________________________
dropout_1 (Dropout) (None, 26, 26, 32) 0
_________________________________________________________________
conv2d_2 (FactorizedConv2DTu (None, 24, 24, 64) 1939
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 64) 0
_________________________________________________________________
dropout_2 (Dropout) (None, 12, 12, 64) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 9216) 0
_________________________________________________________________
dense_1 (FactorizedDense) (None, 128) 37504
_________________________________________________________________
dropout_3 (Dropout) (None, 128) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 1290
=================================================================
Total params: 40,847
Trainable params: 40,847
Non-trainable params: 0
_________________________________________________________________
[0.07411974601857364, 0.9793]
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | - | - | - | - | - | - |