In [1]:
# keras系
from keras import models
from keras import layers
from keras.layers import Input,merge
from keras.layers.core import Reshape,Dense,Dropout,Activation,Flatten,MaxoutDense,Merge
from keras.layers.advanced_activations import LeakyReLU
from keras.layers.convolutional import Convolution2D, MaxPooling2D, ZeroPadding2D, UpSampling2D, Deconvolution2D
from keras.layers.normalization import BatchNormalization
from keras.preprocessing.image import ImageDataGenerator
from keras.preprocessing.image import load_img
from keras.models import Sequential, Model
from keras.optimizers import Adam
from keras.utils.generic_utils import Progbar
from keras.utils.visualize_util import plot
from keras.datasets import cifar100

# その他
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from PIL import Image
import cPickle
import random
import sys
from tqdm import tqdm


Using TensorFlow backend.
/Users/YumaKajihara/.pyenv/versions/anaconda2-2.5.0/lib/python2.7/site-packages/numexpr/cpuinfo.py:76: UserWarning: [Errno 2] No such file or directory
  stacklevel=stacklevel + 1):

In [2]:
def make_trainable(net, val):
    net.trainable = val
    for l in net.layers:
        l.trainable = val

In [11]:
def create_generator(latent_size):
    latent_input = Input(shape=[latent_size])
    perception_input = Input(shape=[12])
    PH = Dense(800, init='glorot_normal')(perception_input)
    H = merge([latent_input, PH], mode='concat', concat_axis=1)
    H = BatchNormalization(mode=2)(H)
    H = Reshape( [5, 5, 40] )(H)
    H = Convolution2D(1024, 3, 3, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(512, 3, 3, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(256, 5, 5, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(128, 5, 5, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(64, 5, 5, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(32, 5, 5, border_mode='same', init='glorot_uniform')(H)
    H = Activation('relu')(H)
    H = UpSampling2D(size=(2, 2))(H)
    H = Convolution2D(1, 5, 5, border_mode='same', init='glorot_uniform')(H)
    g_V = Activation('sigmoid')(H)
    generator_model = Model([latent_input, perception_input], g_V)
    return generator_model

In [4]:
def create_discriminator(img_shape):
    image_input = Input(shape=img_shape)
    perception_input = Input(shape=[12])
    H = Convolution2D(32, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(image_input)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(64, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(128, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(256, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(512, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(1024, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Convolution2D(1024, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = Flatten()(H)
    H = Dense(100)(H)
    H = LeakyReLU(0.2)(H)
    H = Dropout(0.5)(H)
    PH = Dense(100, init='glorot_normal')(perception_input)
    H = merge([H, PH], mode='sum')
    d_V = Dense(2,activation='softmax')(H)
    discriminator_model = Model([image_input, perception_input], d_V)
    return discriminator_model

In [5]:
# 論文にちゃんと書いてなかったぽん。
def create_perception_model(img_shape):
    image_input = Input(shape=img_shape)
    H = Convolution2D(32, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(image_input)
    H = LeakyReLU(0.2)(H)
    H = Dropout(0.5)(H)
    H = Convolution2D(64, 5, 5, subsample=(2, 2), border_mode = 'same', activation='relu')(H)
    H = LeakyReLU(0.2)(H)
    H = Dropout(0.5)(H)
    H = Flatten()(H)
    H = Dense(500, init='glorot_normal')(H)
    H = Dense(500, init='glorot_normal')(H)
    H = Dense(12, init='glorot_normal')(H)
    p_V = Activation('sigmoid')(H)
    perception_model = Model(image_input, p_V)
    return perception_model

In [6]:
class PDTG:
    def __init__(self, latent_size, input_shape):
        self.latent_size = latent_size
        self.input_shape = input_shape
        self.is_model_created = False

    def create_model(self):
        self.generator = create_generator(self.latent_size)
        self.discriminator = create_discriminator(self.input_shape)
        self.perception_model = create_perception_model(self.input_shape)
        gan_input = Input(shape=[self.latent_size])
        perception_input = Input(shape=[12])
        H = self.generator([gan_input, perception_input])
        p_V = self.perception_model(H)
        g_V = self.discriminator([H, perception_input])
        self.g_p_model = Model([gan_input, perception_input], p_V)
        self.g_d_model = Model([gan_input, perception_input], g_V)
        self.model = Model([gan_input, perception_input], [g_V, p_V])
        self.g_p_model.summary()
        self.g_d_model.summary()
        plot(self.model, to_file="pdtg.png", show_shapes=True, show_layer_names=True)
        self.is_model_created = True
        
    def compile_model(self):
        self.generator.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-4))
        self.discriminator.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-4))
        self.perception_model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=1e-4))
        self.g_d_model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=1e-4))
        self.g_p_model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=1e-4))

In [82]:
generator = create_generator(200)
generator.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-4))
generator.summary()
plot(generator, to_file="sample_generator.png", show_shapes=True, show_layer_names=True)
discriminator = create_discriminator((320, 320, 1))
discriminator.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-4))
discriminator.summary()
plot(discriminator, to_file="sample_discriminator.png", show_shapes=True, show_layer_names=True)
perception_model = create_perception_model((320, 320, 1))
perception_model.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-4))
perception_model.summary()
plot(perception_model, to_file="sample_perception_model.png", show_shapes=True, show_layer_names=True)


____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_83 (InputLayer)            (None, 12)            0                                            
____________________________________________________________________________________________________
input_82 (InputLayer)            (None, 200)           0                                            
____________________________________________________________________________________________________
dense_90 (Dense)                 (None, 800)           10400       input_83[0][0]                   
____________________________________________________________________________________________________
merge_27 (Merge)                 (None, 1000)          0           input_82[0][0]                   
                                                                   dense_90[0][0]                   
____________________________________________________________________________________________________
batchnormalization_14 (BatchNorm (None, 1000)          4000        merge_27[0][0]                   
____________________________________________________________________________________________________
reshape_14 (Reshape)             (None, 5, 5, 40)      0           batchnormalization_14[0][0]      
____________________________________________________________________________________________________
convolution2d_125 (Convolution2D (None, 5, 5, 1024)    369664      reshape_14[0][0]                 
____________________________________________________________________________________________________
activation_107 (Activation)      (None, 5, 5, 1024)    0           convolution2d_125[0][0]          
____________________________________________________________________________________________________
upsampling2d_7 (UpSampling2D)    (None, 10, 10, 1024)  0           activation_107[0][0]             
____________________________________________________________________________________________________
convolution2d_126 (Convolution2D (None, 10, 10, 512)   4719104     upsampling2d_7[0][0]             
____________________________________________________________________________________________________
activation_108 (Activation)      (None, 10, 10, 512)   0           convolution2d_126[0][0]          
____________________________________________________________________________________________________
upsampling2d_8 (UpSampling2D)    (None, 20, 20, 512)   0           activation_108[0][0]             
____________________________________________________________________________________________________
convolution2d_127 (Convolution2D (None, 20, 20, 256)   3277056     upsampling2d_8[0][0]             
____________________________________________________________________________________________________
activation_109 (Activation)      (None, 20, 20, 256)   0           convolution2d_127[0][0]          
____________________________________________________________________________________________________
upsampling2d_9 (UpSampling2D)    (None, 40, 40, 256)   0           activation_109[0][0]             
____________________________________________________________________________________________________
convolution2d_128 (Convolution2D (None, 40, 40, 128)   819328      upsampling2d_9[0][0]             
____________________________________________________________________________________________________
activation_110 (Activation)      (None, 40, 40, 128)   0           convolution2d_128[0][0]          
____________________________________________________________________________________________________
upsampling2d_10 (UpSampling2D)   (None, 80, 80, 128)   0           activation_110[0][0]             
____________________________________________________________________________________________________
convolution2d_129 (Convolution2D (None, 80, 80, 64)    204864      upsampling2d_10[0][0]            
____________________________________________________________________________________________________
activation_111 (Activation)      (None, 80, 80, 64)    0           convolution2d_129[0][0]          
____________________________________________________________________________________________________
upsampling2d_11 (UpSampling2D)   (None, 160, 160, 64)  0           activation_111[0][0]             
____________________________________________________________________________________________________
convolution2d_130 (Convolution2D (None, 160, 160, 32)  51232       upsampling2d_11[0][0]            
____________________________________________________________________________________________________
activation_112 (Activation)      (None, 160, 160, 32)  0           convolution2d_130[0][0]          
____________________________________________________________________________________________________
upsampling2d_12 (UpSampling2D)   (None, 320, 320, 32)  0           activation_112[0][0]             
____________________________________________________________________________________________________
convolution2d_131 (Convolution2D (None, 320, 320, 1)   801         upsampling2d_12[0][0]            
____________________________________________________________________________________________________
activation_113 (Activation)      (None, 320, 320, 1)   0           convolution2d_131[0][0]          
====================================================================================================
Total params: 9,456,449
Trainable params: 9,454,449
Non-trainable params: 2,000
____________________________________________________________________________________________________
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_84 (InputLayer)            (None, 320, 320, 1)   0                                            
____________________________________________________________________________________________________
convolution2d_132 (Convolution2D (None, 160, 160, 32)  832         input_84[0][0]                   
____________________________________________________________________________________________________
leakyrelu_118 (LeakyReLU)        (None, 160, 160, 32)  0           convolution2d_132[0][0]          
____________________________________________________________________________________________________
convolution2d_133 (Convolution2D (None, 80, 80, 64)    51264       leakyrelu_118[0][0]              
____________________________________________________________________________________________________
leakyrelu_119 (LeakyReLU)        (None, 80, 80, 64)    0           convolution2d_133[0][0]          
____________________________________________________________________________________________________
convolution2d_134 (Convolution2D (None, 40, 40, 128)   204928      leakyrelu_119[0][0]              
____________________________________________________________________________________________________
leakyrelu_120 (LeakyReLU)        (None, 40, 40, 128)   0           convolution2d_134[0][0]          
____________________________________________________________________________________________________
convolution2d_135 (Convolution2D (None, 20, 20, 256)   819456      leakyrelu_120[0][0]              
____________________________________________________________________________________________________
leakyrelu_121 (LeakyReLU)        (None, 20, 20, 256)   0           convolution2d_135[0][0]          
____________________________________________________________________________________________________
convolution2d_136 (Convolution2D (None, 10, 10, 512)   3277312     leakyrelu_121[0][0]              
____________________________________________________________________________________________________
leakyrelu_122 (LeakyReLU)        (None, 10, 10, 512)   0           convolution2d_136[0][0]          
____________________________________________________________________________________________________
convolution2d_137 (Convolution2D (None, 5, 5, 1024)    13108224    leakyrelu_122[0][0]              
____________________________________________________________________________________________________
leakyrelu_123 (LeakyReLU)        (None, 5, 5, 1024)    0           convolution2d_137[0][0]          
____________________________________________________________________________________________________
convolution2d_138 (Convolution2D (None, 3, 3, 1024)    26215424    leakyrelu_123[0][0]              
____________________________________________________________________________________________________
flatten_27 (Flatten)             (None, 9216)          0           convolution2d_138[0][0]          
____________________________________________________________________________________________________
dense_91 (Dense)                 (None, 100)           921700      flatten_27[0][0]                 
____________________________________________________________________________________________________
leakyrelu_124 (LeakyReLU)        (None, 100)           0           dense_91[0][0]                   
____________________________________________________________________________________________________
input_85 (InputLayer)            (None, 12)            0                                            
____________________________________________________________________________________________________
dropout_40 (Dropout)             (None, 100)           0           leakyrelu_124[0][0]              
____________________________________________________________________________________________________
dense_92 (Dense)                 (None, 100)           1300        input_85[0][0]                   
____________________________________________________________________________________________________
merge_28 (Merge)                 (None, 100)           0           dropout_40[0][0]                 
                                                                   dense_92[0][0]                   
____________________________________________________________________________________________________
dense_93 (Dense)                 (None, 2)             202         merge_28[0][0]                   
====================================================================================================
Total params: 44,600,642
Trainable params: 44,600,642
Non-trainable params: 0
____________________________________________________________________________________________________
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_86 (InputLayer)            (None, 320, 320, 1)   0                                            
____________________________________________________________________________________________________
convolution2d_139 (Convolution2D (None, 160, 160, 32)  832         input_86[0][0]                   
____________________________________________________________________________________________________
leakyrelu_125 (LeakyReLU)        (None, 160, 160, 32)  0           convolution2d_139[0][0]          
____________________________________________________________________________________________________
dropout_41 (Dropout)             (None, 160, 160, 32)  0           leakyrelu_125[0][0]              
____________________________________________________________________________________________________
convolution2d_140 (Convolution2D (None, 80, 80, 64)    51264       dropout_41[0][0]                 
____________________________________________________________________________________________________
leakyrelu_126 (LeakyReLU)        (None, 80, 80, 64)    0           convolution2d_140[0][0]          
____________________________________________________________________________________________________
dropout_42 (Dropout)             (None, 80, 80, 64)    0           leakyrelu_126[0][0]              
____________________________________________________________________________________________________
flatten_28 (Flatten)             (None, 409600)        0           dropout_42[0][0]                 
____________________________________________________________________________________________________
dense_94 (Dense)                 (None, 500)           204800500   flatten_28[0][0]                 
____________________________________________________________________________________________________
dense_95 (Dense)                 (None, 500)           250500      dense_94[0][0]                   
____________________________________________________________________________________________________
dense_96 (Dense)                 (None, 12)            6012        dense_95[0][0]                   
____________________________________________________________________________________________________
activation_114 (Activation)      (None, 12)            0           dense_96[0][0]                   
====================================================================================================
Total params: 205,109,108
Trainable params: 205,109,108
Non-trainable params: 0
____________________________________________________________________________________________________

In [61]:
pdtg = PDTG(200, (320, 320, 1))
pdtg.create_model()


____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_20 (InputLayer)            (None, 200)           0                                            
____________________________________________________________________________________________________
input_21 (InputLayer)            (None, 12)            0                                            
____________________________________________________________________________________________________
model_10 (Model)                 (None, 299, 299, 1)   243124033   input_20[0][0]                   
                                                                   input_21[0][0]                   
____________________________________________________________________________________________________
model_12 (Model)                 (None, 12)            180309108   model_10[1][0]                   
====================================================================================================
Total params: 423,433,141
Trainable params: 423,431,141
Non-trainable params: 2,000
____________________________________________________________________________________________________
____________________________________________________________________________________________________
Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_20 (InputLayer)            (None, 200)           0                                            
____________________________________________________________________________________________________
input_21 (InputLayer)            (None, 12)            0                                            
____________________________________________________________________________________________________
model_10 (Model)                 (None, 299, 299, 1)   243124033   input_20[0][0]                   
                                                                   input_21[0][0]                   
____________________________________________________________________________________________________
model_11 (Model)                 (None, 2)             44600642    model_10[1][0]                   
                                                                   input_21[0][0]                   
====================================================================================================
Total params: 287,724,675
Trainable params: 287,722,675
Non-trainable params: 2,000
____________________________________________________________________________________________________

訓練データ生成


In [7]:
params = [
    "contrast", 
    "repetitive",
    "granular",
    "random",
    "rough",
    "feature density",
    "direction",
    "structural complexity",
    "coarse",
    "regular",
    "oriented",
    "uniform"
]
df = pd.read_csv('texture_database/rating.csv')

max_val = 0.0
min_val = 5.0
for param in params:
    for val in df[param]:
        if max_val < val:
            max_val = val
        if min_val > val:
            min_val = val
print "max : %f, min %f" % (max_val, min_val)
range_num = max_val - min_val
for param in params:
    index = 0
    for val in df[param]:
        df[param][index] = (val - min_val) / range_num
        index = index + 1
#     print df[param]

# 画像を変換
images = []
for i in range(450):
    index = i + 1
    img_path = "./texture_database/textures/" + str(index) + ".png"
    img = load_img(img_path, target_size=(320,320), grayscale=True)
    arr = np.asarray(img)
    arr = arr.tolist()
    image = []
    image.append(arr)
    images.append(image)
images = np.array(images)
print images.shape


max : 8.850000, min 1.000000
(450, 1, 320, 320)

In [8]:
images = images.reshape([450, 320, 320,1])
X_train, X_test = np.vsplit(images, [400])
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255

print np.min(X_train), np.max(X_train)
print('X_train shape:', X_train.shape)
print('Image Shape:', X_train.shape[1:])
print(X_train.shape[0], 'train samples')
print(X_test.shape[0], 'test samples')


0.0 0.937255
('X_train shape:', (400, 320, 320, 1))
('Image Shape:', (320, 320, 1))
(400, 'train samples')
(50, 'test samples')

学習


In [9]:
def plot_loss(losses):
        plt.figure(figsize=(10,8))
        plt.plot(losses["d"], label='discriminitive loss')
        plt.plot(losses["g_d"], label='generative-discriminitive loss')
        plt.plot(losses["g_p"], label='generative-perspective loss')
        plt.plot(losses["p"], label='perspective loss')
        plt.legend()
        plt.show()

In [10]:
def train(pdtg, batch_size, nb_epoch):
    losses = {"d":[], "g_d":[], "g_p":[], "p":[]}
    for e in tqdm(range(nb_epoch)):
        #batchの作成
        indecies = np.random.randint(0,X_train.shape[0],size=batch_size)
        image_batch = X_train[indecies,:,:,:]
        perception_features = df.iloc[indecies].values
        noise_gen = np.random.uniform(0,1,size=[batch_size,200])
        noise_gen_per = np.random.uniform(0,1,size=[batch_size,12])
        generated_images = pdtg.generator.predict([noise_gen, noise_gen_per])
        
        #ジェネった画像でdiscriminatorの学習
        X = np.concatenate((image_batch, generated_images))
        X_2 = np.concatenate((perception_features, noise_gen_per))
        y = np.zeros([2*batch_size,2])
        y[0:batch_size,1] = 1
        y[batch_size:,0] = 1
        d_loss  = pdtg.discriminator.train_on_batch([X, X_2],y)
        losses["d"].append(d_loss)
        
        #ジェネった画像でperception_modelの学習
        p_loss = pdtg.perception_model.train_on_batch(X, X_2)
        losses["p"].append(p_loss)
        
        noise_tr = np.random.uniform(0,1,size=[batch_size,200])
        noise_tr_per = np.random.uniform(0,1,size=[batch_size,12])
        y2 = np.zeros([batch_size,2])
        y2[:,1] = 1
        
        g_d_loss = pdtg.g_d_model.train_on_batch([noise_tr, noise_tr_per],y2)
        losses["g_d"].append(g_d_loss)
        g_p_loss = pdtg.g_p_model.train_on_batch([noise_tr, noise_tr_per],noise_gen_per)
        losses["g_p"].append(g_p_loss)
        # Updates plots
        if e%25==24:
            plot_loss(losses)

In [ ]:
pdtg = PDTG(200, (320, 320, 1))
pdtg.create_model()
pdtg.compile_model()
train(pdtg, 30, 20)


  0%|          | 0/20 [00:00<?, ?it/s]

In [54]:
indecies = np.random.randint(0,X_train.shape[0],size=50)
print indecies[:]
print df.iloc[indecies].values


[ 78 167 351  46 210 294 187 144 261 189 253 200 378  53 292 388 214 241
  26  62 328 389 395 358 383 363 117  36 122 137 321  27 222 315 289  17
 366 284 216 350 249 373 279   2 385 171 305 387 351 188]
[[ 0.23566879  0.2611465   0.14649682  0.64968153  0.71974522  0.22929936
   0.14649682  0.39490446  0.39490446  0.1910828   0.19745223  0.43949045]
 [ 0.42675159  0.33757962  0.59235669  0.70700637  0.33757962  0.66878981
   0.14012739  0.57324841  0.56050955  0.20382166  0.22929936  0.42038217]
 [ 0.59872611  0.57324841  0.59872611  0.70700637  0.36305732  0.67515924
   0.14012739  0.42675159  0.54140127  0.33757962  0.14012739  0.52866242]
 [ 0.60509554  0.43949045  0.12738854  0.29936306  0.47770701  0.52229299
   0.6433121   0.30573248  0.55414013  0.55414013  0.73248408  0.54140127]
 [ 0.38853503  0.55414013  0.21019108  0.4522293   0.47770701  0.55414013
   0.61783439  0.40127389  0.47770701  0.47770701  0.64968153  0.57324841]
 [ 0.33121019  0.84076433  0.42038217  0.12738854  0.57961783  0.75796178
   0.68789809  0.46496815  0.55414013  0.78980892  0.79617834  0.8089172 ]
 [ 0.42038217  0.38216561  0.10191083  0.41401274  0.5477707   0.32484076
   0.75796178  0.31210191  0.50318471  0.49044586  0.70063694  0.44585987]
 [ 0.59872611  0.66242038  0.40764331  0.30573248  0.34394904  0.36942675
   0.22292994  0.49681529  0.56687898  0.53503185  0.37579618  0.6433121 ]
 [ 0.1910828   0.66878981  0.33757962  0.24203822  0.57961783  0.75796178
   0.82802548  0.2611465   0.59872611  0.71974522  0.73248408  0.68789809]
 [ 0.2866242   0.21019108  0.42675159  0.60509554  0.34394904  0.49681529
   0.21019108  0.35031847  0.54140127  0.21019108  0.20382166  0.42038217]
 [ 0.29936306  0.87261146  0.37579618  0.24840764  0.59872611  0.77707006
   0.71974522  0.3566879   0.63057325  0.91082803  0.84713376  0.9044586 ]
 [ 0.10828025  0.10191083  0.03821656  0.75796178  0.6433121   0.22292994
   0.01910828  0.0955414   0.44585987  0.06369427  0.08280255  0.32484076]
 [ 0.50318471  0.39490446  0.63694268  0.61783439  0.3566879   0.40127389
   0.18471338  0.48407643  0.39490446  0.33121019  0.1910828   0.38853503]
 [ 0.43949045  0.52866242  0.40127389  0.33121019  0.49681529  0.46496815
   0.37579618  0.38853503  0.44585987  0.57961783  0.40764331  0.63694268]
 [ 0.29299363  0.68152866  0.31847134  0.28025478  0.57324841  0.70700637
   0.61146497  0.40764331  0.75159236  0.63057325  0.63694268  0.82165605]
 [ 0.0955414   0.12738854  0.52866242  0.46496815  0.50955414  0.88535032
   0.05732484  0.22292994  0.53503185  0.32484076  0.15286624  0.76433121]
 [ 0.3566879   0.40127389  0.56687898  0.64968153  0.42675159  0.64968153
   0.35031847  0.43312102  0.52866242  0.42038217  0.37579618  0.49681529]
 [ 0.81528662  0.92993631  0.17197452  0.05732484  0.45859873  0.47770701
   0.54140127  0.81528662  0.36305732  0.92356688  0.58598726  0.75159236]
 [ 0.30573248  0.32484076  0.66242038  0.69426752  0.38216561  0.67515924
   0.15923567  0.38216561  0.4522293   0.2611465   0.15286624  0.5477707 ]
 [ 0.51592357  0.41401274  0.22292994  0.56687898  0.36942675  0.44585987
   0.1910828   0.46496815  0.40764331  0.38853503  0.27388535  0.45859873]
 [ 0.41401274  0.29299363  0.22292994  0.61783439  0.49681529  0.44585987
   0.23566879  0.41401274  0.45859873  0.20382166  0.2611465   0.42038217]
 [ 0.1656051   0.19745223  0.56687898  0.49044586  0.42675159  0.75796178
   0.15923567  0.26751592  0.46496815  0.22292994  0.18471338  0.53503185]
 [ 0.12738854  0.28025478  0.54140127  0.5477707   0.45859873  0.89171975
   0.14649682  0.1910828   0.61146497  0.2866242   0.14649682  0.61146497]
 [ 0.17834395  0.17834395  0.14012739  0.73248408  0.68789809  0.33121019
   0.21019108  0.31847134  0.52229299  0.14649682  0.31210191  0.36942675]
 [ 0.21019108  0.22292994  0.12738854  0.59235669  0.73248408  0.12101911
   0.48407643  0.22929936  0.29299363  0.29299363  0.40127389  0.37579618]
 [ 0.46496815  0.56050955  0.72611465  0.57324841  0.30573248  0.77707006
   0.36305732  0.33757962  0.56050955  0.45859873  0.40127389  0.64968153]
 [ 0.47770701  0.72611465  0.29299363  0.1910828   0.40764331  0.61783439
   0.52866242  0.52229299  0.50318471  0.78343949  0.47133758  0.72611465]
 [ 0.76433121  0.43949045  0.7388535   0.76433121  0.38216561  0.43312102
   0.1910828   0.52229299  0.54140127  0.28025478  0.22292994  0.42675159]
 [ 0.5477707   0.44585987  0.43949045  0.56050955  0.47770701  0.49681529
   0.28025478  0.65605096  0.37579618  0.43312102  0.36942675  0.43312102]
 [ 0.51592357  0.2866242   0.29299363  0.63057325  0.43949045  0.31210191
   0.15923567  0.6433121   0.45859873  0.29936306  0.24840764  0.27388535]
 [ 0.40127389  0.29299363  0.31847134  0.68789809  0.31210191  0.55414013
   0.10828025  0.33757962  0.45859873  0.17197452  0.17834395  0.39490446]
 [ 0.69426752  0.47133758  0.1910828   0.47133758  0.38216561  0.51592357
   0.17834395  0.63694268  0.51592357  0.39490446  0.32484076  0.38853503]
 [ 0.48407643  0.6433121   0.36305732  0.2611465   0.5477707   0.4522293
   0.43949045  0.39490446  0.40764331  0.50955414  0.51592357  0.74522293]
 [ 0.43312102  0.91719745  0.5477707   0.11464968  0.57961783  0.77070064
   0.84713376  0.3566879   0.5477707   0.91719745  0.82165605  0.95541401]
 [ 0.19745223  0.85350318  0.59235669  0.19745223  0.6433121   0.94904459
   0.60509554  0.33121019  0.70700637  0.82165605  0.65605096  0.89171975]
 [ 0.72611465  0.26751592  0.14649682  0.77070064  0.43312102  0.34394904
   0.12738854  0.64968153  0.49044586  0.22292994  0.20382166  0.30573248]
 [ 0.46496815  0.35031847  0.10191083  0.50955414  0.50955414  0.47133758
   0.70700637  0.30573248  0.42675159  0.36305732  0.67515924  0.37579618]
 [ 0.17197452  0.84076433  0.49681529  0.13375796  0.63694268  0.91082803
   0.59235669  0.28025478  0.62420382  0.8343949   0.71974522  0.84713376]
 [ 0.29299363  0.50955414  0.3566879   0.44585987  0.49044586  0.59235669
   0.61783439  0.45859873  0.5477707   0.45859873  0.61783439  0.61146497]
 [ 0.42038217  0.58598726  0.87261146  0.57324841  0.38853503  0.86624204
   0.0955414   0.29299363  0.74522293  0.2611465   0.21656051  0.61146497]
 [ 0.82802548  0.9044586   0.25477707  0.13375796  0.57961783  0.47770701
   0.46496815  0.63057325  0.51592357  0.88535032  0.50318471  0.76433121]
 [ 0.43949045  0.46496815  0.65605096  0.62420382  0.49681529  0.57961783
   0.24840764  0.35031847  0.52866242  0.29299363  0.29936306  0.53503185]
 [ 0.25477707  0.79617834  0.47133758  0.14012739  0.71974522  0.87898089
   0.58598726  0.34394904  0.77070064  0.75796178  0.57961783  0.75159236]
 [ 0.30573248  0.24203822  0.49681529  0.77070064  0.35031847  0.70700637
   0.10828025  0.38853503  0.70063694  0.20382166  0.0955414   0.3566879 ]
 [ 0.21019108  0.29936306  0.23566879  0.60509554  0.61783439  0.36942675
   0.29299363  0.30573248  0.31210191  0.3566879   0.2866242   0.39490446]
 [ 0.2866242   0.22929936  0.49681529  0.63057325  0.42675159  0.8089172
   0.03184713  0.33757962  0.56050955  0.14012739  0.12738854  0.59872611]
 [ 0.21656051  0.7388535   0.31847134  0.15923567  0.6433121   0.81528662
   0.61146497  0.43312102  0.56687898  0.75796178  0.65605096  0.8343949 ]
 [ 0.14012739  0.36942675  0.56050955  0.53503185  0.56050955  0.93630573
   0.10828025  0.1910828   0.56050955  0.17834395  0.15923567  0.61146497]
 [ 0.59872611  0.57324841  0.59872611  0.70700637  0.36305732  0.67515924
   0.14012739  0.42675159  0.54140127  0.33757962  0.14012739  0.52866242]
 [ 0.42675159  0.33757962  0.14012739  0.5477707   0.51592357  0.36942675
   0.55414013  0.34394904  0.40127389  0.35031847  0.46496815  0.43312102]]

In [ ]: