Lesson 1 discussion

Exactly right

Yes, it is a way to do transfer learning

We will discuss that in lesson 2

It’s installed automatically in the AWS AMI. If you’re not using that, you’ll need to install it yourself. If you’ve followed our advice and are using anaconda, just type conda install bcolz . If you’re not following our advice and are using anaconda, you may want to reconsider - otherwise you’ll have to figure out how to fix the pip install :wink:

2 Likes

iTerm2 is very useful and seems a lot easier, thanks again

1 Like

Hey @mclasson What is your setup while running the Model of VGG16?
This might be an issue with not having the supported installations for your machine, either GPU or the drivers related such as cuDnn, are those things in place?

Please look at your keras configuration. It might be configured for tensorflow.

I faced the same issue.
To solve the issue I have changed the keras configuration file.
~/.keras/keras.json
{
“image_dim_ordering”: “th”,
“epsilon”: 1e-07,
“floatx”: “float32”,
“backend”: “theano”
}

Thanks. I had two problems. g++ missing and keras using Tensorflow as you suggested. Now I instead get this one:
Exception: The shape of the input to “Flatten” is not fully defined (got (0, 7, 512). Make sure to pass a complete “input_shape” or “batch_input_shape” argument to the first layer in your model. after printing this

(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)
(Subtensor{int64}.0, Elemwise{add,no_inplace}.0, Elemwise{add,no_inplace}.0, Subtensor{int64}.0)

Beautiful! Helped me a lot. Thanks

Is there a way to save the trained model so it can be reused by loading it?

You can use model.save(filepath) and model.load_model(filepath) .

See https://keras.io/getting-started/faq/

You can also save the “training”, the model weights, with model.save_weights(filepath) and model.load_weights(filepath).

2 Likes

Is the ‘weights’ exactly the same as a model? In another word, does “model_save” function the same as “save_weights”?

Training accuracy VS validation accuracy. In lesson 1, I trained on a small portion of the data, a little more than 1000 instances.

Why is the highest training accuracy is under 90%, but the validation accuracy is still over 97%?
1655/1655 [==============================] - 1047s - loss: 0.5973 - acc: 0.8749 - val_loss: 0.1039 - val_acc: 0.9759

I am also using a smaller validation set.

1 Like

model.save(filepath) saves everything.
model.save_weights(filepath) save only the the weights. You need the actual model definition.

1 Like

Why is the highest training accuracy is under 90%, but the validation accuracy is still over 97%?

Keep going with the videos. This is covered in detail in Lesson 3.

1 Like

batch_size = 64
vgg = Vgg16()
path = "data/redux/"
vgg.model.load_model(path+‘results/model.h5’)

I tested with replacing “load_weights” with ‘load_model’, however, I received this error:

Using Theano backend.
Traceback (most recent call last):
File “/home/abigail/workspace/fast-ai/redux_test.py”, line 14, in
vgg.model.load_model(path+‘results/model.h5’)
AttributeError: ‘Sequential’ object has no attribute ‘load_model’

Why can’t it load?

1 Like

I never used it
but

You probably do not need "vgg = Vgg16()"
and it should be “vgg=”, it should return the model.
vgg=model.load_model(path+‘results/model.h5’)

@james_goldfarb, i think i know what’s going on. It would take a while to modify the code to use load and save ‘model’ in lesson one, due to the use of the pretrained model.

You probably didn’t set image_dim_ordering to th. See the post immediately above yours.

Where to enable theano for Keras in Vgg16?

According to Keras documentations, https://keras.io/getting-started/faq/#how-can-i-run-keras-on-gpu. In order to run GPU on theano, it needs to do something like this:

import theano
theano.config.device = 'gpu’
theano.config.floatX = ‘float32’

However, I can’t see where this is set in either Utility.py or vgg16.py. Hi, @jeremy, could you shed some light on this? Just curious.