regarding converting 1D to 2D in tensorflow - tensorflow

Given a one dimensional data, how to re-shape it to 2D matrix so that I can leverage the existing 2D convolution in tensorflow?

I have to assume that you are talking about an array. If that is correct then you should be able to convert it using reshape.
from the tensorflow site
https://www.tensorflow.org/api_docs/python/tf/reshape

Related

How to covert 2d tensor to 3d tensor in TensorFlow

I am working on TensorFlow and I have a 2d tensor with the shape (50,2). How can I convert this tensor to a new shape (None,50,2)?
You can try using the Embedding Layer as it would preserve information while increasing dimensions along with serving your purpose. Embedding produces a 3-D tensor - more information here from official docs

How to have a multidimensional input rnn with legacy_seq2seq

For legacy_seq2seq, it just supports the input with a list of 2D Tensors.
If a model has more parameters for each inputs. says,
[[1,2], [2,3], [3,4]...] instead of [1, 2, 3, 4, ....], it cant use legacy_seq2seq to have batch methods.
So, how to implement a multidimensional input rnn in batch method with tensorflow?
Or it doesnt exist?
Multi-dimensional RNNs are well supported in Tensorflow, but not added to the legacy seq2seq interface. Please use the current (dynamic_rnn) API and you'll see that multi-dimensional tensors work fine (there are even pre-made multi-dimensional RNN cells in contrib).

index rows from 2D tensor

Suppose I have a 2D tensor A of floats, and a 1D tensor B of ints. The numbers in B represent indices to the rows of A. How do I efficiently perform a lookup of this indices inside a tensorflow graph?
Have you already tried tf.gather() ?
See also this question: TensorFlow: using a tensor to index another tensor

What is a 2D float tensor?

Disclamer: I know nothing about CNN and deep learning and I don't know Torch.
I'm using SIFT for my object recognition application. I found this paper Discriminative Learning of Deep Convolutional Feature Point Descriptors which is particularly interesting because it's CNN based, which are more precise than classic image descripion methods (e.g. SIFT, SURF etc.), but (quoting the abstract):
using the L2 distance during both training and testing we develop
128-D descriptors whose euclidean distances reflect patch similarity,
and which can be used as a drop-in replacement for any task involving
SIFT
Wow, that's fantastic: that means that we can continue to use any SIFT based approach but with more precise descriptors!
However, quoting the github code repository README:
Note the output will be a Nx128 2D float tensor where each row is a
descriptor.
Well, what is a "2D float tensor"? SIFT descriptors matrix is Nx128 floats, is there something that I am missing?
2D float tensor = 2D float matrix.
FYI: The meaning of tensors in the neural network community
This is a 2-d float tensor.
[[1.0,2.0],
[3.0,4.0]]
This is still a 2-d float tensor, even if they have 3 items, and 3 rows!
[[1.0,2.0,3.0],
[4.0,5.0,6.0],
[7.0,5.0,6.0]]
The number of bracket is what matters.

RBF Kernel on Masked array

I wonder if there is a way to compute the Gaussian kernel of a numpy masked array?
I import:
from sklearn.metrics.pairwise import rbf_kernel
If one uses a masked array and gives it as the input to the rbf_kernel function of scikit learn package the result is not a masked array. It seems that all the pairwise distances are calculated regardless of some of them being masked!
Scikit-learn doesn't support masked arrays.
Computing the RBF kernel is really simple if you can compute euclidean distances, though.