MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / build_feature_extractor

Function build_feature_extractor

rl2/a3c/nets.py:4–36  ·  view source on GitHub ↗
(input_)

Source from the content-addressed store, hash-verified

2
3
4def build_feature_extractor(input_):
5 # We only want to create the weights once
6 # In all future calls we should set reuse = True
7
8 # scale the inputs from 0..255 to 0..1
9 input_ = tf.to_float(input_) / 255.0
10
11 # conv layers
12 conv1 = tf.contrib.layers.conv2d(
13 input_,
14 16, # num output feature maps
15 8, # kernel size
16 4, # stride
17 activation_fn=tf.nn.relu,
18 scope="conv1")
19 conv2 = tf.contrib.layers.conv2d(
20 conv1,
21 32, # num output feature maps
22 4, # kernel size
23 2, # stride
24 activation_fn=tf.nn.relu,
25 scope="conv2")
26
27 # image -> feature vector
28 flat = tf.contrib.layers.flatten(conv2)
29
30 # dense layer
31 fc1 = tf.contrib.layers.fully_connected(
32 inputs=flat,
33 num_outputs=256,
34 scope="fc1")
35
36 return fc1
37
38class PolicyNetwork:
39 def __init__(self, num_outputs, reg=0.01):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected