log0 / neural-style-painting

Implementing of the "A Neural Algorithm of Artistic Style"
236 stars 100 forks source link

Reconstruct FC layers with your *.mat file #7

Open JGuillaumin opened 7 years ago

JGuillaumin commented 7 years ago

Hi,

I would to reconstruct all the layers from the VGG network, with fully-connected layers. In the *.mat file, the layer with id '37' corresponds to the first FC layer. Weights and biases have shapes : [7,7,512,4096] and [1,4096].

W, b = _weights(37, 'fc6')
print(W.shape)
print(b.shape)
>>> (7, 7, 512, 4096)
>>>  (4096, 1)

The input tensor is from 'avgpool5' : Tensor("VGG_3/avgpool_5/AvgPool:0", shape=(1, 7, 7, 512), dtype=float32)

This shape (for W) seems to correspond to an operation that combines "flatten + matmul" .. but I don't find an operation with TensorFlow which can handle those variables ..

After, for the next FC layers, weights and biases have normal shapes :

W, b = _weights(39, 'fc7')
print(W.shape)
print(b.shape)

>>> (1, 1, 4096, 4096)
>>> (4096, 1)

Did you find a solution to reconstruct the whole network ?

I'm creating a workshop about Style Transfer, with TensorFlow. And I would like to give an example of classification with the whole VGG.

Thanks