I know there are some ways to use specific convolution fliter like dilated convolution by using the op tf.nn.atrous_conv2d.But if I want to realize the structure like Convolution in Convolution for Network in Network.,how can I change the fliter of the op liketf.nn.conv2d.
Is writing a brand new op the only way to achieve that?
Or if I would like to use data transformation to realize it, will the automatic differentiation work? Is there any document to use data transformation?
Related
In the U-net, have activation functions in all the layers but there seems to be no activation function in the upsampling layer (that is done using transpose convolution). Why does this offer more efficiency than having an activation function?
From my understanding, activation functions offer non-linearity. So, this question really is, what benefit is there to maintaining linearity in transpose convolutions but maintaining non-linearity on regular convolutions. Wouldn't it just always be best to have an activation function in these layers?
My only other intuition is that perhaps, they're trying to keep the upsampling as closely related to regular morphological interpolation methods.
I think your interpretation is right: they were just trying to keep the process similar to the upsampling operated with classic interpolations because of a better interpretability of the architecture (while still allowing flexibility to the network, that can still learn the best weights for the upsampling). In general, if you want to add more non-linearity, you can enter any desired activation function (such as a ReLU) after that level, but personally, from my experience, I would say that performance will not change much.
In the original paper (Section 2), there seems to be ReLU activation function in the upsampling path?
"Every step in the expansive path consists of an upsampling of the
feature map followed by a 2x2 convolution (“up-convolution”) that halves the
number of feature channels, a concatenation with the correspondingly cropped
feature map from the contracting path, and two 3x3 convolutions, each followed by a ReLU."
https://arxiv.org/pdf/1505.04597.pdf
The assumption made by the OP is incorrect. The upsampling layers in the UNet do involve an activation function. Below is a screenshot from the video on the page linked by the OP that shows the exact upconvolution operation used in UNet. You can see that they use ReLU in this operation.
I want to label some documents, I tried the LDA algorithm but the results were too messy. I decided to use a supervised approach, so I created my own topic-word matrix but I don't know how to generate a document-topic matrix. Do you know some good topic modeling algorithm that can be trained using topic-word matrix ?
If you do have a correct topic-word matrix created. You only need to compute the weights of topic for each documents. For example you could use the occurence of each word in each documents and then summing the topic weight of those words. You might need to add some coefficients like number of occurence but it is pretty straightforward.
You can also use LDA algorithm but ignoring the training step which is made to process the topic-word matrix. I do not know which implementation you use but following the one of Sklearn you can directly pass the matrix as components_ attributes and then use the transform function.
The output of PCA are the eigenvectors and eigenvalues of the covariance (or correlation) matrix of the original data. Let's say the are $x_1,...,x_n$ columns, then, there are $z_1,...,z_n$ eigenvalues and $\tilde{z_1},...,\tilde{z_n}$ eigenvectors. My question are:
can I use the value $\tilde{z_1}^{(1)},...,\tilde{z_1}^{(n)}$ of the first (or also the other) eigenvector as weight of my model? for example as the weight of the columns $x_1,...,x_n$, a kind of Unsupervised method.
I understand the weight $\tilde{z_1}^{(1)},...,\tilde{z_1}^{(n)}$ as the contribution value of every column. Is it correct?
Can I use Spearman or Kendall correlation instead of covariance? Is it going to change the results?
I know that is it not a conventional way to use PCA but I would like to know if it makes sense.
First of all, you can do whatever you want my friend. It's your model and you can use it in the way you want.
However, I wouldn't do that. PCA is a way to reduce dimensionality, you lose data to train your model faster. PCA can be seen as if you reduce a sphere of 3 dimensions to a circle of 2 dimensions. In some situations it can be useful.
With the output of PCA you can train your model and see what you get. However, have you tried to train your model without PCA? Maybe you don't need it and you are losing information that would improve your model
When I execute a SVM with a training set and a validation set i check results with a confusion matrix, and all is good.
After that, how can i implement a system "query by example": i give a picture and return most similar image in an image set ( based on a threshold)?
There are example in python (with scikit-learn module)?
Retrieving similar images does not need a classifier. It is usually a Nearest Neighbor Problem, most likely have features with high-dimensions. The keys are to find:
What character of image you care most? shape? colors? color distribution? object?
What are the best features to describe the character of image? If it's color, then you might want R/G/B values or histograms.
How do you want to measure the similarity? i.e., the distance function.
Which algorithm you want to use in such a NearestNeighbor problem setup? Options include and not limited to: kd-tree, locality-sensitive-hashing, etc. Here has some good discussions.
I need to do matrix operations (mainly multiply and inverse) of a sparse matrix SparseMat in OpenCV.
I noticed that you can only iterate and insert values to SparseMat.
Is there an external code I can use? (or am I missing something?)
It's just that sparse matrices are not really suited for inversion or matrix-matrix-multiplication, so it's quite reasonable there is no builtin function for that. They're actually more used for matrix-vector multiplication (usually when solving iterative linear systems).
What you can do is solve N linear systems (with the columns of the identity matrix as right hand sides) to get the inverse matrix. But then you need N*N storage for the inverse matrix anyway, so using a dense matrix with a usual decompositions algorithm would be a better way to do it, as the performance gain won't be that high when doing N iterative solutions. Or maybe some sparse direct solvers like SuperLU or TAUCS may help, but I doubt that OpenCV has such functionalities.
You should also think if you really need the inverse matrix. Often such problem are also solvable by just solving a linear system, which can be done with a sparse matrix quite easily and fast via e.g. CG or BiCGStab.
You can convert a SparseMat to a Mat, do what operations you need and then convert back.
you can use Eigen library directly. Eigen works together with OpenCV very well.