Closed Silk760 closed 5 years ago
Hi!
It seems that the flatten node you removed and then added back misbehaves: Flatten()(model.outputs) has shape (B * 512) instead of (B, 512).
Try removing 3 last layers instead of 4 and thus avoid adding your own flatten, it seems to work for me.
BTW, when you figure it out, I would be very happy to see you VGG example as a pull request to the tutorials section :)
Hi , I think I figure out the problem which is model.ouputs for some reason does not behave as supposed to be. So I use model.get_layer('block5_pool').output
x= model.get_layer('block5_pool').output
x = Flatten(name='flatten')(x)
x= t3f.nn.KerasDense(input_dims=[4,8,4,4],output_dims=[8,8,8,8], tt_rank=16 ,activation='relu' ,kernel_initializer='glorot',bias_initializer= 1e-7)(x)
x= t3f.nn.KerasDense(input_dims=[8,8,8,8], output_dims=[8,8,8,8], tt_rank=16 ,activation='relu' ,kernel_initializer='glorot',bias_initializer= 1e-7)(x)
predictions = Dense(10, activation="softmax")(x)
model_final = Model(inputs = model.input, outputs = predictions)
However after trying to train the model, I think the model is stuck is not able to train at all , give me a random accuracy which is only 10%. I think the train done on cpu instead of the GPU even I assigned my model to be trained on gpu
Epoch 1/100
- 547s - loss: nan - acc: 0.1049 - val_loss: nan - val_acc: 0.1000
Epoch 2/100
- 548s - loss: nan - acc: 0.0998 - val_loss: nan - val_acc: 0.1000
Epoch 3/100
- 548s - loss: nan - acc: 0.1002 - val_loss: nan - val_acc: 0.1000
Epoch 4/100
- 569s - loss: nan - acc: 0.1003 - val_loss: nan - val_acc: 0.1000
Epoch 5/100
- 577s - loss: nan - acc: 0.0999 - val_loss: nan - val_acc: 0.1000
I have read your tutorial , and I am not really sure if I should do this step , and If I should can you please tell me why
W = model.trainable_weights[0]
print(W)
Wtt = t3f.to_tt_matrix(W, shape=[[7, 4, 7, 4], [5, 5, 5, 5]], max_tt_rank=16)
print(Wtt)
cores = sess.run(Wtt.tt_cores)
other_params = model.get_weights()[1:]
finally I think I am not able to train the model on the GPU , even I wrote this line of code
with K.tf.device('/gpu:0'):
model
So, I read in docs the library support the GPU but when I am learn my model and assign the learning on the gpu does not do it , and learn the graph in CPU instead.
And yes I will put all the models after I finish them.
Hey @MohammedAlnemari , I've written an example similar to yours from scratch (https://gist.github.com/KhrulkovV/c34442ff7fcdf45010a16371bd87a65b) and it seems to be working (I haven't waited for a long time, but at first epoch, accuracy went to something about 40%). I think since the VGG16 architecture is adapted for 224x224 images you need to chop more layers (I removed everything after block3_pool, and then augmented the network with TT--layers. Hope this is useful!
Thanks @KhrulkovV!
It seems that the original issue is resolved so I'll close it. @MohammedAlnemari, feel free to open a new one if you have troubles getting good results on VGG.
I am using VGG-16 for cifar-10 I am trying to use your library in order to reduce the number of parameters in fully connected layers
I am using Keras model = vgg16.VGG16(include_top=True, weights=None,input_shape=(32,32,3),input_tensor= None ,pooling='max',classes=10)
model.load_weights("cifar10vgg_final_weight.h5")
using this code to remove the layers :
When I am trying to train this new model show me the error which is coming from multiply 4069 * batch_size is 128
I am not really sure what cause this problem, the same method work when I build the model from scratch not using VGG keras model, I am not really sure why this is happening