Skip to Main Content
Python Deep Learning Projects
book

Python Deep Learning Projects

by Matthew Lamons, Rahul Kumar, Abhishek Nagaraja
October 2018
Intermediate to advanced content levelIntermediate to advanced
472 pages
10h 57m
English
Packt Publishing
Content preview from Python Deep Learning Projects

Training the model

Following are the steps to train the model:

  1. Load the weights that we downloaded and use them to initialize the model:
weight_reader = WeightReader(wt_path)weight_reader.reset()nb_conv = 23for i in range(1, nb_conv+1):
    conv_layer = model.get_layer('conv_' + str(i))
    
    if i < nb_conv:
        norm_layer = model.get_layer('norm_' + str(i))
        
        size = np.prod(norm_layer.get_weights()[0].shape)

        beta  = weight_reader.read_bytes(size)
        gamma = weight_reader.read_bytes(size)
        mean  = weight_reader.read_bytes(size)
        var   = weight_reader.read_bytes(size)

        weights = norm_layer.set_weights([gamma, beta, mean, var])       
        
    if len(conv_layer.get_weights()) > 1:
        bias   = weight_reader.read_bytes(np.prod(conv_layer.get_weights()[1].shape))
        kernel = weight_reader ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Python Deep Learning for the Web

Hands-On Python Deep Learning for the Web

Anubhav Singh, Sayak Paul

Publisher Resources

ISBN: 9781788997096Supplemental Content