GithubHelp home page GithubHelp logo

cgorman / tensorflow-som Goto Github PK

View Code? Open in Web Editor NEW
77.0 9.0 34.0 102 KB

A multi-gpu implementation of the self-organizing map in TensorFlow

License: MIT License

Python 100.00%
tensorflow neural-networks self-organizing-map unsupervised-learning

tensorflow-som's People

Contributors

cgorman avatar jacobfv avatar kleinyuan avatar nitishkannan23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow-som's Issues

Fix get_centroids and map_vects functions

Hey,

I have been using your code to learn SOM and run few iterations on my data. But I find the functions get_centroids and map_vects seem to be out of place. Can you please fix these functions according to you tf_som.py code. It will be helpful in my SOM learning process.

Thanks!

Speed up the quantization of data

Thanks for building this package,
Using your package, I have learned weight matrix for SOM. Now, I need to do quantization (assign the learned weights) of all the data points (~500 million) used for training and as well as new data points based on learned SOM model. Is there any faster way (batch processing) rather than looping on each data point and assigning the "Best Matching Units"? Looping takes forever for quantization.

Thanks

Alpha value seems to grow with epochs

I have noticed that my initial learning rate value didn't have any meaning for results of the training. After some analysis I have found a part of the code which has raised my eyebrows:

tensorflow-som/tf_som.py

Lines 255 to 260 in e69ed79

alpha = tf.subtract(self._initial_learning_rate,
tf.multiply(self._epoch,
tf.divide(tf.cast(tf.subtract(self._initial_learning_rate, 1),
tf.float32),
tf.cast(tf.subtract(self._max_epochs, 1),
tf.float32))))

It seems that alpha value grows with each iteration linearly from 0 to 1 regardless of the initial_learning_rate value set in the constructor. I expect that alpha value should decay overtime (if I understand its meaning correctly) starting from the learning rate going towards 0.

Radius value decreases from initial value to 1 in last iteration - this is correct so no issue here.

Mini-batch training incorrectly implemented?

If I've read the source code right, batch_size is only used in the train function. And there it doesn't affect the training loop in any way but the number of loops being epochs * batch_size. So now each epoch of training is just repeated a bunch of times.

Is it intentional? I think one should divide the data into batch_size-sized chunks and perform one training step with that data, then move on until all data is used. Then the next epoch. It's even noted in the docstring:

:param batch_size: Number of input vectors to train on at a time

Maybe I missed something, but in case I didn't, here's an issue. Or maybe batch training without the "mini" is intended to just repeat the training. Anyways.

Cheers!

Cannot create a tensor proto whose content is larger than 2GB

when i tried to call SelfOrganizingMap initialization with input_tensor equalt to an array that has size greater than 2 GB i got this error. can i do any thing to fix this issue ?

this is how i tried to call the functions

som = tf_som.SelfOrganizingMap(300, 128, 2, gpus=1,input_tensor=descriptors)
som.train(descriptors.shape[0])

descriptors is a matrix of size (6312149, 128) and has size of nearly 3 GB

this is the traceback generated by pycharm 2018.2.4

Traceback (most recent call last):
File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper preferred_dtype=default_dtype)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1146, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 229, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 506, in make_tensor_proto
"Cannot create a tensor proto whose content is larger than 2GB.")

ValueError: Cannot create a tensor proto whose content is larger than 2GB.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 524, in _apply_op_helper
values, as_ref=input_arg.is_ref).dtype.name

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1146, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 229, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 506, in make_tensor_proto
"Cannot create a tensor proto whose content is larger than 2GB.")

ValueError: Cannot create a tensor proto whose content is larger than 2GB.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Pattern Recognition v2/sift.py", line 405, in
som = tf_som.SelfOrganizingMap(300, 128, 2, gpus=1,input_tensor=descriptors)

File "C:\Pattern Recognition v2\tf_som.py", line 112, in init
self._initialize_tf_graph()

File "C:\Pattern Recognition v2\tf_som.py", line 166, in _initialize_tf_graph
tower_updates.append(self._tower_som())

File "C:\Pattern Recognition v2\tf_som.py", line 219, in _tower_som
self._input = tf.identity(self._input_tensor)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 81, in identity
return gen_array_ops.identity(input, name=name)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 4103, in identity
"Identity", input=input, name=name)

File "C:\Users\ahmed\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 528, in _apply_op_helper
(input_name, err))

ValueError: Tried to convert 'input' to a tensor and failed. Error: Cannot create a tensor proto whose content is larger than 2GB.

Where is Jupyter Notebook?

On SelfOrganizingMap.__init__, there is a parameter called output_sensitivity whose description is "The constant controlling the width of the activity gaussian. See the Jupyter Notebook for an explanation.", but the repository has no notebook.

Fix _make_activity_op

I am completely new to tensor flow, but I think I might have found a bug.

I was trying to get the network output with _make_activity_op, but the function would only return a empty tensor. After changing:

dist = tf.norm(tf.subtract(
tf.expand_dims(self._weights, axis=0),
tf.expand_dims(input_tensor, axis=1)),
name="Distance")

to

dist = tf.norm(tf.subtract(
tf.expand_dims(self._weights, axis=0),
tf.expand_dims(input_tensor, axis=1)),
name="Distance", axis = 2)

the output would be just fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.