O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. First, we start with loading the libraries, as follows:
import osimport globimport tensorflow as tf
  1. Because our task is slightly more complicated than outputting the predicted class, we need to define a function that extracts the values from different layers:
def extract_layers(vgg_layer3_out, vgg_layer4_out, vgg_layer7_out, n_classes):    decode_layer1_preskip0 = tf.layers.conv2d_transpose(vgg_layer7_out, 512, (2, 2), (2, 2), name='decode_layer1_preskip0')    decode_layer1_preskip1 = tf.layers.conv2d(vgg_layer4_out, 512, (1, 1), (1, 1), name='decode_layer1_preskip1')    decode_layer1_out = tf.add(decode_layer1_preskip0, decode_layer1_preskip1, name='decode_layer1_out')    decode_layer2_preskip0 = tf.layers.conv2d_transpose(decode_layer1_out, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required