cgorman / tensorflow-som Goto Github PK
View Code? Open in Web Editor NEWA multi-gpu implementation of the self-organizing map in TensorFlow
License: MIT License
A multi-gpu implementation of the self-organizing map in TensorFlow
License: MIT License
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.
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:
Lines 255 to 260 in e69ed79
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.
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!
most of the map values becomes 0.
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.
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!
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
hey i was trying to run your example code. It stopped and gave the error Tensorflow does not have attribute named Sessions
Could you please guide
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.