MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _highway

Method _highway

tensorflow/contrib/rnn/python/ops/rnn_cell.py:1296–1313  ·  view source on GitHub ↗
(self, inp, out)

Source from the content-addressed store, hash-verified

1294 return self._cell.zero_state(batch_size, dtype)
1295
1296 def _highway(self, inp, out):
1297 input_size = inp.get_shape().with_rank(2).dims[1].value
1298 carry_weight = vs.get_variable("carry_w", [input_size, input_size])
1299 carry_bias = vs.get_variable(
1300 "carry_b", [input_size],
1301 initializer=init_ops.constant_initializer(self._carry_bias_init))
1302 carry = math_ops.sigmoid(nn_ops.xw_plus_b(inp, carry_weight, carry_bias))
1303 if self._couple_carry_transform_gates:
1304 transform = 1 - carry
1305 else:
1306 transform_weight = vs.get_variable("transform_w",
1307 [input_size, input_size])
1308 transform_bias = vs.get_variable(
1309 "transform_b", [input_size],
1310 initializer=init_ops.constant_initializer(-self._carry_bias_init))
1311 transform = math_ops.sigmoid(
1312 nn_ops.xw_plus_b(inp, transform_weight, transform_bias))
1313 return inp * carry + out * transform
1314
1315 def __call__(self, inputs, state, scope=None):
1316 """Run the cell and add its inputs to its outputs.

Callers

nothing calls this directly

Calls 3

with_rankMethod · 0.80
get_shapeMethod · 0.45
get_variableMethod · 0.45

Tested by

no test coverage detected