-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Update utils.py and Create test_utils_predict.py #566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
10ce5d4
Update utils.py
2wins 151958e
Update utils.py
2wins 445690e
Merge branch 'master' into patch-5
2wins e504c85
Merge branch 'master' into patch-5
DEKHTIARJonathan 5d6ad68
Merge branch 'master' into patch-5
DEKHTIARJonathan ce3ef61
Create test_utils_predict.py
2wins d274464
Update utils.py
2wins f494d8c
Update test_utils_predict.py
2wins 619c08f
Update CHANGELOG.md
2wins 2546d64
Merge remote-tracking branch 'origin/patch-1' into patch-5
2wins cb48f7d
Merge branch 'patch-5' of https://github.com/2wins/tensorlayer into p…
2wins e259cfe
Update test_utils_predict.py
2wins 5ccc7a9
Update CHANGELOG.md
2wins a904ae7
Update CHANGELOG.md
2wins a0be0c9
Update CHANGELOG.md
2wins 67cce87
Merge branch 'master' into patch-5
zsdonghao 346f23b
Update test_utils_predict.py
2wins a9a0091
Reflect the latest update
2wins 147e893
Update test_utils_predict.py
2wins f9bd69f
Update test_utils_predict.py
2wins be46a1b
Update test_utils_predict.py
2wins c31bc43
Update test_utils_predict.py
2wins 532c3b8
Update test_utils_predict.py (fix Bad Coding Style)
2wins 0cb228f
Update test_utils_predict.py
2wins cee22df
Update CHANGELOG.md
2wins d3c4346
Update CHANGELOG.md
2wins cb1ebb7
Merge branch 'master' into patch-5
2wins 99fa99b
Update CHANGELOG.md
2wins fd4a01c
Update CHANGELOG.md
2wins 89e8535
Merge branch 'master' into patch-5
DEKHTIARJonathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import unittest | ||
|
||
try: | ||
from tests.unittests_helper import CustomTestCase | ||
except ImportError: | ||
from unittests_helper import CustomTestCase | ||
|
||
import tensorflow as tf | ||
import tensorlayer as tl | ||
import numpy as np | ||
|
||
|
||
class Util_Predict_Test(CustomTestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.x1 = tf.placeholder(tf.float32, [None, 5, 5, 3]) | ||
cls.x2 = tf.placeholder(tf.float32, [8, 5, 5, 3]) | ||
cls.X1 = np.ones([127, 5, 5, 3]) | ||
cls.X2 = np.ones([7, 5, 5, 3]) | ||
cls.batch_size = 8 | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
tf.reset_default_graph() | ||
|
||
def test_case1(self): | ||
with self.assertNotRaises(Exception): | ||
with tf.Session() as sess: | ||
n = tl.layers.InputLayer(self.x1) | ||
y = n.outputs | ||
y_op = tf.nn.softmax(y) | ||
tl.utils.predict(sess, n, self.X1, self.x1, y_op, batch_size=self.batch_size) | ||
sess.close() | ||
|
||
def test_case2(self): | ||
with self.assertRaises(Exception): | ||
with tf.Session() as sess: | ||
n = tl.layers.InputLayer(self.x2) | ||
y = n.outputs | ||
y_op = tf.nn.softmax(y) | ||
tl.utils.predict(sess, n, self.X2, self.x2, y_op, batch_size=self.batch_size) | ||
sess.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# tf.logging.set_verbosity(tf.logging.INFO) | ||
tf.logging.set_verbosity(tf.logging.DEBUG) | ||
|
||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it normal that they do not use the same batch_size ? It is usual a thin that we don't want to do...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the error, I was correct:
https://travis-ci.org/tensorlayer/tensorlayer/jobs/378752347#L1003
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes we set the shape of
tf.placeholder
explicitly using a specific batch size.However, it becomes a problem when the number of samples is not a factor of the batch size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.