main.py
def load_vgg(sess, vgg_path):
    """
    Load Pretrained VGG Model into TensorFlow.
    :param sess: TensorFlow Session
    :param vgg_path: Path to vgg folder, containing "variables/" and "saved_model.pb"
    :return: Tuple of Tensors from VGG model (image_input, keep_prob, layer3_out, layer4_out, layer7_out)
    """
    # TODO: Implement function
    #   Use tf.saved_model.loader.load to load the model and weights
    vgg_tag = 'vgg16'
    vgg_input_tensor_name = 'image_input:0'
    vgg_keep_prob_tensor_name = 'keep_prob:0'
    vgg_layer3_out_tensor_name = 'layer3_out:0'
    vgg_layer4_out_tensor_name = 'layer4_out:0'
    vgg_layer7_out_tensor_name = 'layer7_out:0'


    tf.saved_model.loader.load(sess,[vgg_tag],vgg_path);

    #print the tensor names:
    for tensor in tf.get_default_graph().as_graph_def().node:
        print (tensor.name) 

    image_input = tf.get_default_graph().get_tensor_by_name(vgg_input_tensor_name)
    keep_prob = tf.get_default_graph().get_tensor_by_name(vgg_keep_prob_tensor_name)
    layer3_out = tf.get_default_graph().get_tensor_by_name(vgg_layer3_out_tensor_name)
    layer4_out = tf.get_default_graph().get_tensor_by_name(vgg_layer4_out_tensor_name)
    layer7_out = tf.get_default_graph().get_tensor_by_name(vgg_layer7_out_tensor_name)
    
    return image_input, keep_prob, layer3_out, layer4_out, layer7_out

    Load Pretrained VGG Model into TensorFlow.
    :param sess: TensorFlow Session
    :param vgg_path: Path to vgg folder, containing "variables/" and "saved_model.pb"
    :return: Tuple of Tensors from VGG model (image_input, keep_prob, layer3_out, layer4_out, layer7_out)
    
Load Pretrained VGG Model into TensorFlow.
Load Pretrained VGG Model into TensorFlow .
def load_vgg(sess, vgg_path):
    vgg_tag = 'vgg16'
    vgg_input_tensor_name = 'image_input:0'
    vgg_keep_prob_tensor_name = 'keep_prob:0'
    vgg_layer3_out_tensor_name = 'layer3_out:0'
    vgg_layer4_out_tensor_name = 'layer4_out:0'
    vgg_layer7_out_tensor_name = 'layer7_out:0'
    tf.saved_model.loader.load(sess,[vgg_tag],vgg_path);
    for tensor in tf.get_default_graph().as_graph_def().node:
        print (tensor.name) 
    image_input = tf.get_default_graph().get_tensor_by_name(vgg_input_tensor_name)
    keep_prob = tf.get_default_graph().get_tensor_by_name(vgg_keep_prob_tensor_name)
    layer3_out = tf.get_default_graph().get_tensor_by_name(vgg_layer3_out_tensor_name)
    layer4_out = tf.get_default_graph().get_tensor_by_name(vgg_layer4_out_tensor_name)
    layer7_out = tf.get_default_graph().get_tensor_by_name(vgg_layer7_out_tensor_name)
    return image_input, keep_prob, layer3_out, layer4_out, layer7_out
def load_vgg ( sess , vgg_path ) : vgg_tag = 'vgg16' vgg_input_tensor_name = 'image_input:0' vgg_keep_prob_tensor_name = 'keep_prob:0' vgg_layer3_out_tensor_name = 'layer3_out:0' vgg_layer4_out_tensor_name = 'layer4_out:0' vgg_layer7_out_tensor_name = 'layer7_out:0' tf . saved_model . loader . load ( sess , [ vgg_tag ] , vgg_path ) ; for tensor in tf . get_default_graph ( ) . as_graph_def ( ) . node : print ( tensor . name ) image_input = tf . get_default_graph ( ) . get_tensor_by_name ( vgg_input_tensor_name ) keep_prob = tf . get_default_graph ( ) . get_tensor_by_name ( vgg_keep_prob_tensor_name ) layer3_out = tf . get_default_graph ( ) . get_tensor_by_name ( vgg_layer3_out_tensor_name ) layer4_out = tf . get_default_graph ( ) . get_tensor_by_name ( vgg_layer4_out_tensor_name ) layer7_out = tf . get_default_graph ( ) . get_tensor_by_name ( vgg_layer7_out_tensor_name ) return image_input , keep_prob , layer3_out , layer4_out , layer7_out
Load Pretrained VGG Model into TensorFlow.
Load Pretrained VGG Model into TensorFlow .
"""
    Load Pretrained VGG Model into TensorFlow.
    :param sess: TensorFlow Session
    :param vgg_path: Path to vgg folder, containing "variables/" and "saved_model.pb"
    :return: Tuple of Tensors from VGG model (image_input, keep_prob, layer3_out, layer4_out, layer7_out)
    """ # TODO: Implement function #   Use tf.saved_model.loader.load to load the model and weights #print the tensor names:
Tuple of Tensors from VGG model (image_input, keep_prob, layer3_out, layer4_out, layer7_out)
Tuple of Tensors from VGG model ( image_input keep_prob layer3_out layer4_out layer7_out )
sess
None
vgg_path
Path to vgg folder, containing "variables/" and "saved_model.pb"
Path to vgg folder containing " variables / " and " saved_model . pb "