Skip to content

Instantly share code, notes, and snippets.

@zhpmatrix
Created September 6, 2017 13:35
Show Gist options
  • Save zhpmatrix/adde9a31eb21a1fdb25f19854aaf9730 to your computer and use it in GitHub Desktop.
Save zhpmatrix/adde9a31eb21a1fdb25f19854aaf9730 to your computer and use it in GitHub Desktop.
代码笔记
返回Logistic Regression中的预测错误的样本:
float(sum( labels != (preds > 0.0) ) ) / len(labels)
核心逻辑:对于Sigmoid函数,y = 1 / 1 + exp(-x),当x > 0 时,y = 1, 当 x < 0 时, y = 0.
@zhpmatrix
Copy link
Author

sess资源释放

sess = tf.Session()
result = sess.run(product)
sess.close()

当使用with结构的时候,不需要显式的资源释放。
with tf.Session() as sess:
result = sess.run(product)
print(result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment