geifmany / cifar-vgg Goto Github PK
View Code? Open in Web Editor NEWVGG16 models for CIFAR-10 and CIFAR-100 using Keras
License: GNU General Public License v3.0
VGG16 models for CIFAR-10 and CIFAR-100 using Keras
License: GNU General Public License v3.0
When evaluating this model with cifar100 weights, I get accrucay of 0.17.
However, when training again I get 0.68%
I cloned the repository and its stuck at displaying "Epoch 1/250" and no training is happening. Also I doubt where is the cifar10 dataset getting downloaded? cifar10.load_data()
right? Is it that because its downloading the dataset, that's why its stuck at Epoch 1/250? Once it gets downloaded the training will start?
P.S. I don't have GPU.
Hello,
Your code works very well, but why do I get empty list when I fo get_weights of the model after loading the weights? I have done two small modification in your code in order to save the model and the weights.
Change 1: A save function in the class cifar10vgg
def save(self):
model_json = self.model.to_json()
self.model.save_weights('./model/model_cifar10vgg_weights.h5')
self.model.save('./model/model_cifar10vgg.h5')
with open('./model/model_cifar10vgg.json', 'w') as json_file:
json_file.write(model_json)
Change 2: model.save() in the main loop
When I try to implement
import tensorflow.keras.backend as K
from tensorflow.keras.models import model_from_json
from tensorflow.keras.models import load_model
K.clear_session()
with open('./model/model_cifar10vgg.json', 'r') as f:
model = model_from_json(f.read())
model = load_model('./model/model_cifar10vgg.h5')
model.load_weights("./model/model_cifar10vgg_weights.h5")
model.summary()
print("model.layers[-2].get_weights()", model.layers[-1].get_weights())
The output is:
model.layers[-2].get_weights() []
How do the image sizes change through the net? Is 32 px input width enough?
Would it be possible to change the license to something permissive, e.g. MIT? The current choice (Gpl 3) disallows using your code in permissively licensed repositories.
Hi Geifmany,
I tried your vanilla code here to understand how Keras works.
But when I run it, the model experience loss : nan and acc: ~0.10
Did you also experience it?
If not, is there any parameter that you tune?
Hi, I cannot get a right result, when I run CIFAR100, I got accuracy=0.01
Apologies in advance; I am new to this stuff.
Thanks,
Ankit
Using TensorFlow backend.
(10, 4)
WARNING:tensorflow:From /Users/mengfan/PycharmProjects/untitled1/venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
File "/Users/mengfan/PycharmProjects/untitled1/VGG2.py", line 370, in
main()
File "/Users/mengfan/PycharmProjects/untitled1/VGG2.py", line 312, in main
model = VGG()
File "/Users/mengfan/PycharmProjects/untitled1/VGG2.py", line 120, in init
self.model = self.train(self.model)
File "/Users/mengfan/PycharmProjects/untitled1/VGG2.py", line 291, in train
validation_data=(X_test, y_test),callbacks=[reduce_lr],verbose=2)
File "/Users/mengfan/PycharmProjects/untitled1/venv/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/Users/mengfan/PycharmProjects/untitled1/venv/lib/python3.6/site-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/Users/mengfan/PycharmProjects/untitled1/venv/lib/python3.6/site-packages/keras/engine/training_generator.py", line 40, in fit_generator
model._make_train_function()
File "/Users/mengfan/PycharmProjects/untitled1/venv/lib/python3.6/site-packages/keras/engine/training.py", line 496, in _make_train_function
raise RuntimeError('You must compile your model before using it.')
RuntimeError: You must compile your model before using it.
Process finished with exit code 1
出现这个问题如何解决
I read the paper " Very Deep Convolutional Neural Network Based Image Classification Using
Small Training Sample Size" carefully and found the following difference between the code and the original paper?
We add Batch Normalization layer before every nonlinearity. (that's mean before "Relu activation function ") but here it after it ?
The momentum, base learning rate and base weight decay rate are set to be 0.9, 0.001, 0.006 (but here the learning rate starts from 0.1 ? )
"mini-batch SGD" is used by the original paper, but here it's SGD .
could you please explain it me ?
Hello, I just wanted to ask a question to clarify about your computed weights. Did you initialize them with the weights from the original VGG-16 network, or did you start from random initializations when you trained?
Here's what I got. I wonder if I did anything wrong or should I change any paras?
Epoch 8/250
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.