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

Method __init__

rl2/mountaincar/pg_tf.py:123–152  ·  view source on GitHub ↗
(self, D, ft, hidden_layer_sizes=[])

Source from the content-addressed store, hash-verified

121# approximates V(s)
122class ValueModel:
123 def __init__(self, D, ft, hidden_layer_sizes=[]):
124 self.ft = ft
125 self.costs = []
126
127 # create the graph
128 self.layers = []
129 M1 = D
130 for M2 in hidden_layer_sizes:
131 layer = HiddenLayer(M1, M2)
132 self.layers.append(layer)
133 M1 = M2
134
135 # final layer
136 layer = HiddenLayer(M1, 1, lambda x: x)
137 self.layers.append(layer)
138
139 # inputs and targets
140 self.X = tf.placeholder(tf.float32, shape=(None, D), name='X')
141 self.Y = tf.placeholder(tf.float32, shape=(None,), name='Y')
142
143 # calculate output and cost
144 Z = self.X
145 for layer in self.layers:
146 Z = layer.forward(Z)
147 Y_hat = tf.reshape(Z, [-1]) # the output
148 self.predict_op = Y_hat
149
150 cost = tf.reduce_sum(tf.square(self.Y - Y_hat))
151 self.cost = cost
152 self.train_op = tf.train.AdamOptimizer(1e-1).minimize(cost)
153
154 def set_session(self, session):
155 self.session = session

Callers

nothing calls this directly

Calls 2

forwardMethod · 0.95
HiddenLayerClass · 0.70

Tested by

no test coverage detected