Repository navigation
Add synthetic datasets - #5315
Conversation
|
Can one of the admins verify this patch? |
|
@zafartahirov, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ilblackdragon, @tensorflower-gardener and @keveman to be potential reviewers. |
|
Sorry about two commits -- should have rebased it before pushing |
|
BTW, an unrelated question, what is TFs and Google's policy on rebasing the commits -- do I have to rebase to the current origin/HEAD before submitting a PR? Also, do I need to squash intermediate (minor) commits? Sorry, I am new to TF contributions, and don't know where to find these answers |
ilblackdragon
left a comment
There was a problem hiding this comment.
On your contribution questions:
When we merge in - we are going to squash all commits and rebase it on head, but for this your code needs to be cleanly applied (e.g. right now that would fail).
| print('Successfully downloaded', filename, size, 'bytes.') | ||
| return filepath | ||
|
|
||
| def split_into_train_and_test(dataset, test_ratio=0.3, shuffle=False): |
There was a problem hiding this comment.
we have this function here - https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/estimators/_sklearn.py#L168 if you want to just pull it out from there to here and refer from _sklearn part - would be great.
There was a problem hiding this comment.
I am not sure I understand the comment -- should I pull the splitting routine from the _sklearn completely and place it here, or should I just refer to _sklearn from here.
There was a problem hiding this comment.
Pull it out and place it here (and just refer from there).
There was a problem hiding this comment.
I have not touched the file in the _sklearn -- There are some compatibility issues, namely:
-- _sklearn._train_test_split expects variable arguments, and uses .take() to extract the values. Current implementation expects base.Dataset as an imput. If I replace it with the implementation in this PR, it will break any other codes.
-- _sklearn._train_test_split returns tuples, while the contrib.learn methods return either base.Dataset or base.Datasets, which are not iterable per se.
I could completely nuke the _sklearn method, but it is potentially dangerous. Please, advise
| else: | ||
| return DATASETS[name]() | ||
|
|
||
| def make_synthetic(name='circles', n_samples=100, noise=None, *args, **kwargs): |
There was a problem hiding this comment.
let's not have name with default value.
| /util/python/python_lib | ||
| /pip_test | ||
| /_python_build | ||
| **/tools/git/gen |
There was a problem hiding this comment.
hm, is this really needed?
There was a problem hiding this comment.
For some reason the gen folder is being generated on my machine, and it is pointing to my .git folder
There was a problem hiding this comment.
I'm just not sure it should be in the general .gitignore. You can just add this to your local .git/info/exclude
| """Creates binary synthetic datasets | ||
|
|
||
| Args: | ||
| name: Name of the dataset to generate (optional, str, default='circles') |
There was a problem hiding this comment.
usually we write comments like this name: str, name of the dataset to generate.
(the optional and default are easily readable from the function's definition)
| - Note that the `noise` parameter uses `numpy.random.normal` and depends on `numpy`'s seed | ||
|
|
||
| TODO: | ||
| - Support custom seed for replicability |
There was a problem hiding this comment.
I would add this now - and set it by default to some number.
| TODO: | ||
| - Support custom seed for replicability | ||
| - Support multiclass datasets | ||
| - Need shuffling routine. Currently synthetic datasets are reshuffled to avoid train/test correlation, |
There was a problem hiding this comment.
nothing to change, but tf.learn automatically shuffle training data when fit is called.
|
@ilblackdragon -- Will fix the CL over the weekend |
|
I have gone through the comments by @ilblackdragon and fixed most of them. The one I didn't touch is in the inline comments for the code. I have also included some unittests |
|
@ilblackdragon I have covered your reviews (all except one), also included a new routine -- spiral generation, and placed unittests. |
|
Done with all changes @ilblackdragon I have removed the |
ilblackdragon
left a comment
There was a problem hiding this comment.
Sorry for late reply. Few more comments, otherwise looks good.
| # ============================================================================== | ||
|
|
||
| """Module includes reference datasets and utilities to load datasets.""" | ||
| """Module includes reference datasets and utilities to load datasets. It also |
There was a problem hiding this comment.
first line of comments in modules (and functions) should be one line, you rephrase to something like:
Dataset utilities and synthetic/reference datasets.
| srcs = ["load_csv_test.py"], | ||
| srcs = [ | ||
| "load_csv_test.py", | ||
| "synthetic_test.py" |
There was a problem hiding this comment.
can you please split this into two tests in build file?
it's preferred to have tests separate to allow better parallelism.
| return DATASETS[name](size, test_with_fake_data) | ||
| else: | ||
| return DATASETS[name]() | ||
|
|
There was a problem hiding this comment.
what's nit - Unit of entropy? Sorry, was trying to find it, but the only thing comes to mind is "not important thing"?
There was a problem hiding this comment.
nit - is "nitpicking", picking to small things. we use it apologize for nitpicking to style (giving Google code style requirements, like 2 lines between functions/classes, spaces etc)
| # limitations under the License. | ||
| # ============================================================================== | ||
|
|
||
| """Module includes reference datasets and utilities to load datasets. It also |
There was a problem hiding this comment.
here probably should be just Synthetic dataset generators.
| if noise is not None: | ||
| X += np.random.normal(scale=noise, size=X.shape) | ||
| return Dataset(data=X[indices], target=y[indices]) | ||
|
|
There was a problem hiding this comment.
two new lines between functions (and same below)
| class SyntheticTest(tf.test.TestCase): | ||
| """Test synthetic dataset generation | ||
|
|
||
| TODO (tests): |
There was a problem hiding this comment.
May be something?
TODO: Added tests for next cases:
-
-
we usually use TODO(username) so currently it refers to user 'tests' :)
There was a problem hiding this comment.
Oh woops! :) I completely removed it - I forgot it was a list for myself for corner cases
|
@ilblackdragon Can you please check it again, I submitted the CL |
|
@tensorflow-jenkins Test this please |
|
Oh snap! I am on it! |
|
For some reason it passes all the tests on my machine -- going to rebase it to the HEAD, and see if anything new is breaking it. Is there any way I could get the Travis' logs to see what exactly fails? |
|
It's a python3 error, and an easy fix. Look at the full log here: If you want to check locally, make sure to configure and run using python3. |
|
@martinwicke Thanks for pointing out the Python 3 issue, it was a minor @martinwicke @ilblackdragon That actually raises a question -- is it possible to have |
|
@tensorflow-jenkins Test this please |
|
OK, I don't think this is something I can fix -- there is a problem with |
|
Restarted the failing build (only) at http://ci.tensorflow.org/job/tensorflow-pull-requests-gpu/2815/ @danmane, if that passes, it's fine to merge. |
|
@danmane I think this once could be merged -- Thank you! |
|
Thanks for this! |
|
I got |
This reverts commit ca29fa3. Reason for rollback: Broke builds due to errors such as: File "/workspace/pip_test/venv/local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/__init__.py", line 29, in <module> from tensorflow.contrib.learn.python.learn.datasets import synthetic ImportError: cannot import name synthetic
Revert "Add synthetic datasets (#5315)"
This reverts commit 181fa20.
This is only one possible synthetic dataset. Following methods added + sample code:
Files modified/added:
/.gitignore: **/tools/git/gen is not necessary to commit (for dev only)/tensorflow/contrib/learn/python/learn/datasets/__init__.py: Added the support formake_syntheticandsplit_data/tensorflow/contrib/learn/python/learn/datasets/base.py: Added new methodsplit_into_train_and_test/tensorflow/contrib/learn/python/learn/datasets/synthetic.py: Created a file to hold all synthetic generators