-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathtf_softmax_layer.py
More file actions
28 lines (20 loc) · 860 Bytes
/
tf_softmax_layer.py
File metadata and controls
28 lines (20 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''
softmax_layer.py : generic SoftMax inference() method for TensorFlow
Adapted from:
https://github.com/darksigma/Fundamentals-of-Deep-Learning-Book/blob/master/fdl_examples/chapter3/logistic_regression_updated.py
Copyright (C) 2017 Jack Baird, Alex Cantrell, Keith Denning, Rajwol Joshi,
Simon D. Levy, Will McMurtry, Jacob Rosen
This file is part of AirSimTensorFlow
MIT License
'''
import tensorflow as tf
def inference(x, xsize, ysize, W_vals=0, b_vals=0):
'''
This is a general-purpose softmax inference layer implementation.
'''
W_init = tf.constant_initializer(value=W_vals)
b_init = tf.constant_initializer(value=b_vals)
W = tf.get_variable('W', [xsize, ysize], initializer=W_init)
b = tf.get_variable('b', [ysize], initializer=b_init)
output = tf.nn.softmax(tf.matmul(x, W) + b)
return output