Giter VIP home page Giter VIP logo

spectralnet's Introduction

SpectralNet

cc

SpectralNet is a python library that performs spectral clustering with deep neural networks.

Link to the paper - SpectralNet

New PyTorch implementation

We recommend using our new (2023) well-maintained PyTorch implementation in the following link - PyTorch SpectralNet

requirements

To run SpectralNet, you'll need Python 3.x and the following python packages:

  • scikit-learn
  • tensorflow==1.15
  • keras==2.3
  • munkres
  • annoy
  • h5py

You will also need wget to download the Reuters dataset, which for MacOS can be installed with

brew install wget

downloading and preprocessing reuters

To run SpectralNet on the Reuters dataset, you must first download and preprocess it. This can be done by

cd path_to_spectralnet/data/reuters/; ./get_data.sh; python make_reuters.py

usage

To use SpectralNet on MNIST, Reuters, the nested 'C' dataset (as seen above), or the semi-supervised and noisy nested 'C' dataset, please run

cd path_to_spectralnet/src/applications; python run.py --gpu=gpu_num --dset=mnist|reuters|cc|cc_semisup

To use SpectralNet on a new dataset, simply pass a tuple to get_data (a function in src/core/data.py) containing four elements in the following order: (x_train, x_test, y_train, y_test). Then define the appropriate hyperparameters and call spectralnet.run(). (See example)

example script

import sys, os
# add directories in src/ to path
sys.path.insert(0, 'path_to_spectralnet/src/')

# import run_net and get_data
from spectralnet import run_net
from core.data import get_data

# define hyperparameters
params = {
    'dset': 'new_dataset',
    'val_set_fraction': ...,
    'siam_batch_size': ...,
    'n_clusters': ...,
    'affinity': ...,
    'n_nbrs': ...,
    'scale_nbrs': ...,
    'siam_k': ...,
    'siam_ne': ...,
    'spec_ne': ...,
    'siam_lr': ...,
    'spec_lr': ...,
    'siam_patience': ...,
    'spec_patience': ...,
    'siam_drop': ...,
    'spec_drop': ...,
    'batch_size': ...,
    'siam_reg': ...,
    'spec_reg': ...,
    'siam_n': ...,
    'siamese_tot_pairs': ...,
    'arch': [
        {'type': 'relu', 'size': ...},
        {'type': 'relu', 'size': ...},
        {'type': 'relu', 'size': ...},
        ],
    'use_approx': ...,
    }
    
# load dataset
x_train, x_test, y_train, y_test = load_new_dataset_data()
new_dataset_data = (x_train, x_test, y_train, y_test)

# preprocess dataset
data = get_data(params, new_dataset_data)

# run spectral net
x_spectralnet, y_spectralnet = run_net(data, params)

For more information on what each hyperparameter means, see src/applications/run.py

spectralnet's People

Contributors

kstant0725 avatar lihenryhfl avatar ushaham 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  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  avatar  avatar  avatar  avatar  avatar  avatar

spectralnet's Issues

Input own similarity matrix?

Thanks for the implementation. We have a similarity matrix W, and we were wondering if we could use SpectralNet to learn embeddings (in the spectral basis of the associated Laplacian of the similarity matrix).
It seems that W is being learned as part of the optimization procedure in SpectralNet, but we want to shortcircuit that.

Error running SpectralNet

>python run.py --dset=mnist
Using TensorFlow backend.
Traceback (most recent call last):
  File "run.py", line 16, in <module>
    from spectralnet import run_net
  File "C:\dev\spectral-clustering\SpectralNet\src\applications\spectralnet.py", line 19, in <module>
    from core import train
  File "C:\dev\spectral-clustering\SpectralNet\src\core\train.py", line 5, in <module>
    from keras.engine.training import _make_batches
ImportError: cannot import name '_make_batches'

change dataset and error comes

I have been running the code with the mnist successfully.But when I converted the dataset into 10000 64*64-size pictures of myself,the problem arose.
Embeddings which I use have dimensionality of 10.
Thank you.
Here is the errors:

2019-04-30 16:22:42.154842: I C:\Users\User\Source\Repos\tensorflow\tensorflow\core\kernels\cuda_solvers.cc:159] Creating CudaSolver handles for stream 00000233B3D591D0
2019-04-30 16:22:42.680676: W C:\Users\User\Source\Repos\tensorflow\tensorflow\core\framework\op_kernel.cc:1202] OP_REQUIRES failed at topk_op.cc:92 : Internal: Could not launch TopKKernel: invalid configuration argument.
Traceback (most recent call last):
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1361, in _do_call
return fn(*args)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _run_fn
target_list, status, run_metadata)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InternalError: Could not launch TopKKernel: invalid configuration argument.
[[Node: TopKV2 = TopKV2[T=DT_FLOAT, sorted=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg, TopKV2/k)]]
[[Node: ortho_weights_update/_1413 = _Recv_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_602_ortho_weights_update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/pycharm project/SpectralNet-master - 副本/src/applications/run.py", line 206, in
x_spectralnet, y_spectralnet = run_net(data, params)
File "D:\pycharm project\SpectralNet-master - 副本\src\applications\spectralnet.py", line 95, in run_net
params['spec_ne'])
File "D:\pycharm project\SpectralNet-master - 副本\src\core\networks.py", line 166, in train
batches_per_epoch=100)[0]
File "D:\pycharm project\SpectralNet-master - 副本\src\core\train.py", line 92, in train_step
return_vars_ += np.asarray(K.get_session().run(all_vars, feed_dict=feed_dict)[:len(return_var)])
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 905, in run
run_metadata_ptr)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1137, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1355, in _do_run
options, run_metadata)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1374, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Could not launch TopKKernel: invalid configuration argument.
[[Node: TopKV2 = TopKV2[T=DT_FLOAT, sorted=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg, TopKV2/k)]]
[[Node: ortho_weights_update/_1413 = _Recv_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_602_ortho_weights_update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Caused by op 'TopKV2', defined at:
File "D:/pycharm project/SpectralNet-master - 副本/src/applications/run.py", line 206, in
x_spectralnet, y_spectralnet = run_net(data, params)
File "D:\pycharm project\SpectralNet-master - 副本\src\applications\spectralnet.py", line 90, in run_net
params['n_nbrs'], batch_sizes, siamese_net, x_train, len(x_train_labeled))
File "D:\pycharm project\SpectralNet-master - 副本\src\core\networks.py", line 112, in init
W = costs.knn_affinity(input_affinity, n_nbrs, scale=scale, scale_nbr=scale_nbr)
File "D:\pycharm project\SpectralNet-master - 副本\src\core\costs.py", line 62, in knn_affinity
nn = tf.nn.top_k(-Dx, n_nbrs, sorted=True)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 2308, in top_k
return gen_nn_ops._top_kv2(input, k=k, sorted=sorted, name=name)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 5438, in _top_kv2
"TopKV2", input=input, k=k, sorted=sorted, name=name)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3271, in create_op
op_def=op_def)
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1650, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InternalError (see above for traceback): Could not launch TopKKernel: invalid configuration argument.
[[Node: TopKV2 = TopKV2[T=DT_FLOAT, sorted=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Neg, TopKV2/k)]]
[[Node: ortho_weights_update/_1413 = _Recv_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_602_ortho_weights_update", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

CUDA

Hi authors,

First, congratulations for your work, I really think it is really useful.
I am running the code with the mnist database. I have a NVIDIA GeForce GTX 960M, but when I enter the number of GPU cores as argument and I check the GPU use, it is still 0%. Is there any special configuration or setting that should I use?

Thanks in advance

Save the model

Hi,

I saw you have some pretrained model saved in h5. I wonder how do you save and load the SpectralNet model given that the last layer is a customized Lambda layer? The save() or to_json() or to_yaml() would be invalid. Thank you in advance!

Use own embeddings?

Hi! First of all - many thanks for your great code!
Could you please tell, whether it is possible to use your system with own embeddings?
If yes, how could I do it in a proper way?
I tried it already with pre-trained paragraph2vec vectors, however I probably did smth. wrong, since I am always getting the error with Cholesky decomposition (Cholesky decomposition was not successful. The input might not be valid.) Embeddings which I use have dimensionality of 500. Have you any idea, why it happens?

Many thanks in advance!

version

What is the version of tensorflow and keras

how to use new dataset?

How can I implement SpectralNet on my own pictures for clustering?
don't know how to do pass a tuple to get_data containing four elements in the following order: (x_train, x_test, y_train, y_test).
how to pass and process my own pictures?
Please give me some advice to solve it.Thanks

Mistake in creating pairs from labeled data?

Hi, I notice that in the following code, shouldn't the 2nd create_paris_from_labeled_data use x_val_labeled instead of x_train_labeled? And the 2nd y_train_labeled should be y_val_labeled?

Under data.py, the get_data method

#get pairs for labeled data

class_indices = [np.where(y_train_labeled == i)[0] for i in range(params['n_clusters'])]

pairs_train_labeled, dist_train_labeled = pairs.create_pairs_from_labeled_data(x_train_labeled, class_indices)

class_indices = [np.where(y_train_labeled == i)[0] for i in range(params['n_clusters'])]

pairs_val_labeled, dist_val_labeled = pairs.create_pairs_from_labeled_data(x_train_labeled, class_indices)

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cholesky decomposition was not successful. The input might not be valid.

1
When I tried to run run.py --gpu=gpu_num --dset=mnist,this error came out.
"Traceback (most recent call last):
File "/home/rps/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
return fn(*args)
File "/home/rps/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1312, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/rps/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun
status, run_metadata)
File "/home/rps/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cholesky decomposition was not successful. The input might not be valid.
[[Node: Cholesky = CholeskyT=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]"

Please give me some advice to solve it.Thanks.

#InvalidArgumentError: Input is not invertible.

Hi,Thank you very much for this method and code, I have this problem when I use this method to replace the dataset, the dataset I used is a 5-dimensional array, I would appreciate if you could provide some help
here is the error:
2022-01-19 15:54:13屏幕截图

Model consistency

Hi,

I do not know if you have tested on model consistency, that is, feeding the same data and observe if the prediction is the same. I noticed between line 136 to line 141 in src/core/train.py, the samples used in one batch is different between the Unlabeled and the Orthonorm (as well as the Labeled). The Unlabeled uses sequential data from batch_start to batch_end, but Orthonorm uses random sampling. Is there a reason for this?

for input_type, input_placeholder in inputs.items():
if input_type == 'Unlabeled':
feed_dict[input_placeholder] = x[batch_start:batch_end]
elif input_type == 'Orthonorm':
batch_ids = np.random.choice(len(x), size=min(len(x), batch_sizes[input_type]), replace=False)
feed_dict[input_placeholder] = x[batch_ids]

Question about squared_distance fucntion

Hi!
First of all, thanks for providing this nice work!

While I am looking into the code, I found the squared_distance function is a little bit confusing. If Y is not provided (so Y = X), this function will do an option of X - X and then take the sum. So, isn't the return value zero?

def squared_distance(X, Y=None, W=None):
'''
Calculates the pairwise distance between points in X and Y
X: n x d matrix
Y: m x d matrix
W: affinity -- if provided, we normalize the distance
returns: n x m matrix of all pairwise squared Euclidean distances
'''
if Y is None:
Y = X
# distance = squaredDistance(X, Y)
sum_dimensions = list(range(2, K.ndim(X) + 1))
X = K.expand_dims(X, axis=1)
if W is not None:
# if W provided, we normalize X and Y by W
D_diag = K.expand_dims(K.sqrt(K.sum(W, axis=1)), axis=1)
X /= D_diag
Y /= D_diag
squared_difference = K.square(X - Y)
distance = K.sum(squared_difference, axis=sum_dimensions)
return distance

Another question about the number of clusters K, can I use a relatively larger number when my dataset contains about 1 million samples? For example, over 1000?

Thanks!
Fan

FailedPreconditionError: Attempting to use uninitialized value spectral_net_learning_rate

When I tried to run python3 run.py,this error came out.
ERROR:
Traceback (most recent call last):
File "/home/dxchang/miniconda3/envs/vic36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
return fn(*args)
File "/home/dxchang/miniconda3/envs/vic36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/dxchang/miniconda3/envs/vic36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value spectral_net_learning_rate
[[{{node spectral_net_learning_rate/read}}]]

Pre-trained weights for new data

Hi, could you please help me?
I would like to apply your system on my data, however according to the function embed_data(x, dset) I require pre-trained weights. Is it an essential step in the code? If yes, how could I get the weights?

Many thanks in advance for your answer!

using affinity = "full" breaks the code

Hi,

Thanks for the paper and the code.

In the networks.py and costs.py you have made an arrangement to deal with case where user wants to calculate full affinity matrix and not just knn affinity matrix but if I set "affinity : full" in run.py, it produces an error related to the cholesky factorization of the output of the feed forward NN.

/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Using TensorFlow backend.
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:460: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:461: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:465: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2020-12-20 14:18:42.250842: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2020-12-20 14:18:42.250902: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2020-12-20 14:18:42.250910: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2020-12-20 14:18:42.250917: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2020-12-20 14:18:42.250923: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX512F instructions, but these are available on your machine and could speed up CPU computations.
2020-12-20 14:18:42.250929: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Epoch: 0, loss=184521.364868, val_loss=12510.053711
Traceback (most recent call last):
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
    status, run_metadata)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/contextlib.py", line 88, in __exit__
    next(self.gen)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cholesky decomposition was not successful. The input might not be valid.
	 [[Node: Cholesky = Cholesky[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](add)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 174, in <module>
    x_spectralnet, y_spectralnet = run_net(data, params)
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/applications/spectralnet.py", line 94, in run_net
    params['spec_ne'])
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/networks.py", line 166, in train
    batches_per_epoch=100)[0]
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/train.py", line 92, in train_step
    return_vars_ += np.asarray(K.get_session().run(all_vars, feed_dict=feed_dict)[:len(return_var)])
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run
    run_metadata_ptr)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    options, run_metadata)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cholesky decomposition was not successful. The input might not be valid.
	 [[Node: Cholesky = Cholesky[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](add)]]

Caused by op 'Cholesky', defined at:
  File "run.py", line 174, in <module>
    x_spectralnet, y_spectralnet = run_net(data, params)
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/applications/spectralnet.py", line 89, in run_net
    params['n_nbrs'], batch_sizes, siamese_net, x_train, len(x_train_labeled))
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/networks.py", line 92, in __init__
    self.outputs = stack_layers(self.inputs, self.layers)
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/layer.py", line 104, in stack_layers
    l = Orthonorm(outputs['Orthonorm'], name=layer.get('name'));
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/layer.py", line 39, in Orthonorm
    ortho_weights = orthonorm_op(x)
  File "/home/suraj/Suraj/newfolder/SpectralNet/src/core/layer.py", line 22, in orthonorm_op
    L = tf.cholesky(x_2)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/ops/gen_linalg_ops.py", line 234, in cholesky
    result = _op_def_lib.apply_op("Cholesky", input=input, name=name)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/suraj/anaconda3/envs/suraj-tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Cholesky decomposition was not successful. The input might not be valid.
	 [[Node: Cholesky = Cholesky[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](add)]]

I am very confused here since cholesky factorization is done on the output (Y^T Y) of the NN and that no way related to the affinity matrix, yet it shows an error that cholesky decomposition was not successful. Ideally, changing "affinity" option should not make any changes to output Y of the NN. Any clarification would be very much helpful!

Question about changing dataset and some error

Hi, I try to change dataset to cifar-100.
But I always encounter error message about :
Cholesky decomposition was not successful. The input might not be valid.

And I have tried the method in Question #11 , but it can't work.
I wonder if I need to change the RGB image (3 channel) into Gray image (1 channel) when I load the dataset ?
Or the dataset with 100 classes is not suitable to SpectralNet?
Could you help me figure out what I should tune the parameter , please ?

Thank you very much.

AttributeError: 'Function' object has no attribute 'outputs'

image
When I tried to run run.py --gpu=gpu_num --dset=mnist,this error came out.

Each dataset has different types of 'AttributeError'
for example: for dataset cc : the error is "AttributeError: 'TensorVariable' object has no attribute 'get_shape'"

My OS is: ubuntu 16.04

My package list :

packages in environment at /root/anaconda2/envs/tensorflow_python3:

Name Version Build Channel

absl-py 0.1.10 py36_0
astor 0.6.2 py36_0
binutils_impl_linux-64 2.28.1 had2808c_3
binutils_linux-64 7.2.0 26
bleach 1.5.0 py36_0
ca-certificates 2017.08.26 h1d4fec5_0
certifi 2018.1.18 py36_0
gast 0.2.0 py36_0
gcc_impl_linux-64 7.2.0 habb00fd_3
gcc_linux-64 7.2.0 26
grpcio 1.10.0 py36hf484d3e_0
gxx_impl_linux-64 7.2.0 hdf63c60_3
gxx_linux-64 7.2.0 26
h5py 2.7.1 py36h3585f63_0
hdf5 1.10.1 h9caa474_1
html5lib 0.9999999 py36_0
intel-openmp 2018.0.0 8
keras 2.1.5 py36_0
libedit 3.1 heed3624_0
libffi 3.2.1 hd88cf55_4
libgcc-ng 7.2.0 hdf63c60_3
libgfortran-ng 7.2.0 hdf63c60_3
libgpuarray 0.7.5 h14c3975_0
libprotobuf 3.5.1 h6f1eeef_0
libstdcxx-ng 7.2.0 hdf63c60_3
mako 1.0.7 py36h0727276_0
markdown 2.6.11 py36_0
markupsafe 1.0 py36hd9260cd_1
mkl 2018.0.2 1
mkl-service 1.1.2 py36h17a0993_4
mkl_fft 1.0.1 py36h3010b51_0
mkl_random 1.0.1 py36h629b387_0
munkres 1.0.12
munkres 1.0.7 py36_0 omnia
ncurses 6.0 h9df7e31_2
numpy 1.14.2 py36hdbf6ddf_1
openssl 1.0.2o h20670df_0
pip 9.0.1 py36_5
protobuf 3.5.1 py36hf484d3e_0
pygpu 0.7.5 py36h14c3975_0
python 3.6.4 hc3d631a_3
python-annoy 1.10.0 py36_0 conda-forge
pyyaml 3.12 py36hafb9ca4_1
readline 7.0 ha6073c6_4
scikit-learn 0.19.1 py36h7aa7ec6_0
scipy 1.0.1 py36hfc37229_0
setuptools 39.0.1 py36_0
six 1.11.0 py36h372c433_1
sqlite 3.22.0 h1bed415_0
tensorboard 1.6.0 py36hf484d3e_0
tensorflow 1.6.0 0
tensorflow-base 1.6.0 py36hff88cb2_0
termcolor 1.1.0 py36_1
theano 1.0.1 py36h6bb024c_0
tk 8.6.7 hc745277_3
werkzeug 0.14.1 py36_0
wheel 0.30.0 py36hfd4bba0_1
xz 5.2.3 h55aa19d_2
yaml 0.1.7 had09818_2
zlib 1.2.11 ha838bed_2

My python version: 3.6

About 'use_code_space'

If I rewrite {'use_code_space':False} in mnist_param .Then error came out.
Here is what I am getting on mnist:
image
image

About ‘ Orthonorm’

Thank you for flattening MNIST dataarray to solving the problem.
But now the new error came out.(Still unused code space)
Here is what I am getting on mnist:
2018-09-25 15-37-22

Unsupervised

Hello. First of all, I appreciate your wonderful work.

I have one question. How can I implement spectralnet as unsupervised version?

I think application part is only for the supervised learning with label.

How you divide the train step into Orthogonality step and Gradient step?

Hello, I read your paper and was attracted by the method you use on SpeatralNet's training process. But I can't find the corresponding code in your project.
In my understanding, during the training process of the spectral net, you modify the Orthogonality layer's weight in one epoch, then BP other layer's weight in the next epoch. But I find that your spectral net doesn't distinguish epochs? And all the net layers was trained with the same input data?
could you please explain how the alternate training is implemented?thank you.

Orthonorm layer weights

Hi,
I have some trouble about the orthogonality training steps. I noticed that the orthogonality layer is actually a Keras Lambda layer which only do the simple operation of inputs. More over, the lambda layer has no trainable weights which is not consistent with the paper:
In each orthogonalization step we use the QR decomposition to tune the weights of the last layer.

I have read the code carefully, and I still can't figure out how to train the orthogonality layer to get the orthogonality output.
I'd appreciate it if you could explain it.

Cholesky decomposition unsuccessful

Hi,

This has been asked before. I ran into the cholesky issue repeatedly in spite of trying large batch size. I wonder how is your experience of resolving this issue. Any tips would help, thank you in advance!

not able to reproduce paper results

I have been running the code with the default params, but don't get any substantial decrease in the loss and the results don't look anything like the ones that appear in the paper.
Here is what I am getting on CC
image

image

Please advise on what should be changed in order to achieve results such as in the paper.
Thanks.

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.