Dummy.py 1.4 KB
Newer Older
1 2 3 4 5 6
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# @author: Tiago de Freitas Pereira <tiago.pereira@idiap.ch>

import tensorflow as tf

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
7

8
def dummy(inputs, reuse=False, mode = tf.estimator.ModeKeys.TRAIN, trainable_variables=True):
9 10
    """
    Create all the necessary variables for this CNN
Tiago Pereira's avatar
Tiago Pereira committed
11

12
    **Parameters**
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
13 14 15
        inputs:
        
        reuse:
16
    """
17

18 19 20
    slim = tf.contrib.slim
    end_points = dict()
    
21
    with tf.variable_scope('Dummy', reuse=reuse):
22
    
23 24 25
        initializer = tf.contrib.layers.xavier_initializer()
        
        graph = slim.conv2d(inputs, 10, [3, 3], activation_fn=tf.nn.relu, stride=1, scope='conv1',
26
                            weights_initializer=initializer,
27
                            trainable=trainable_variables)
28 29 30 31 32 33 34 35 36 37 38
        end_points['conv1'] = graph                            
                                
        graph = slim.max_pool2d(graph, [4, 4], scope='pool1')    
        end_points['pool1'] = graph
        
        graph = slim.flatten(graph, scope='flatten1')
        end_points['flatten1'] = graph        

        graph = slim.fully_connected(graph, 50,
                                     weights_initializer=initializer,
                                     activation_fn=None,
39
                                     scope='fc1',
40
                                     trainable=trainable_variables)
41
        end_points['fc1'] = graph
Tiago Pereira's avatar
Tiago Pereira committed
42

43

44
    return graph, end_points
Tiago Pereira's avatar
Tiago Pereira committed
45