Method
get_cost
(self, logits, labels, reg)
Source from the content-addressed store, hash-verified
| 138 | plt.show() |
| 139 | |
| 140 | def get_cost(self, logits, labels, reg): |
| 141 | cost = tf.reduce_mean( |
| 142 | input_tensor=tf.nn.sparse_softmax_cross_entropy_with_logits( |
| 143 | logits=logits, |
| 144 | labels=labels |
| 145 | ) |
| 146 | ) |
| 147 | rcost = sum(tf.nn.l2_loss(p) for p in self.params) |
| 148 | cost += reg*rcost |
| 149 | return cost |
| 150 | |
| 151 | # list_of_logits is an output! |
| 152 | # it is added to using post-order traversal |
Tested by
no test coverage detected