What is a seed in TensorFlow? [duplicate] - tensorflow

This question already has answers here:
What does 'seeding' mean?
(4 answers)
Closed 6 years ago.
I'm a beginner in TensorFlow, and I came across a parameter called seed in most of the functions. Also, it comes as the only parameter in some functions such as tf.set_random_seed(seed). Is this term seed specific to tensorflow? I believe I've surfed the TensorFlow documentation enough but couldn't find a solid answer.

The term "seed" is an abbreviation of the standard term "random seed".
TensorFlow operators that produce random results accept an optional seed parameter. If you pass the same number to two instances of the same operator, they will produce the same sequence of results. If you not pass a number to such an operator, it will produce different results on each execution.

This is not a tensorflow specific term, in fact almost any programming language have a seed for random generators, with a seed you make sure that you can reproduce your results when using random generators(using the same seed two times, would result in the same random number).

Related

How to tell if the t-SNE algorithm produces the same result?

I am studying the t-SNE algorithm and came across a question and found no answer about it. If I have the same dataset and run the t-SNE algorithm multiple times with the same number of iterations and the same number of perplexity, will I get the same views?
Yes, but the condition for this is the same number of perplexity.

Re-cycling the graph architecture

I'm new to tensorflow so apologies of my question is not relevant. I would like to re-cycle the graph implementation of tensorflow for a different purpose than deep-learning. The idea is to use each node to perform some calculations and output either a number or a dictionary to the dependent nodes that will perform some more calculations and so on. At the end, a summary of all the intermediate results is returned. Does a similar use case exist?

Tensorflow: Using one tensor to index slices of another [duplicate]

This question already has answers here:
Get the last output of a dynamic_rnn in TensorFlow
(4 answers)
Closed 4 years ago.
As motivation for this question, I'm trying to use variable length sequences with tf.nn.dynamic_rnn. When I was training with batch_size=1 (one element at a time), everything was going swimmingly, but now I'm trying to increase the batch size, which means zero-padding sequences to the same length.
I've zero-padded (or truncated) all of my sequences up to the max length of 15000.
outputs (from the RNN) has shape [batch_size, max_seq_length, num_units], which for concreteness is right now [16, 15000, 64].
I also create a seq_lengths tensor, which is [batch_size], so [16], corresponding to the actual sequence length of all the zero-padded sequences.
I've added a fully connected layer, to multiply what was previously outputs[:,-1,:] by W, then add a bias term, since ultimately I'm just trying to predict a single value (or rather batch_size values). However, now, I can't just naively use -1 as the index, because all of the sequences have been variously padded! I have seq_lengths, but I'm not sure exactly how to use it to index outputs. I've searched around, and I think the answer is some clever use of tf.gather_nd, but I can't quite figure it out. I can easily see how to take individual values, but I want to preserve entire slices. Do I need to create some sort of enormous 3D mask?
Here's what I want in terms of a Python comprehension (outputs is an np.array): outputs = np.array([outputs[i, seq_lengths[i], :] for i in range(batch_size)]).
I'd appreciate any help! Thank you.
Actually, Alex it turns out you've already answered my question for me :).
After some more research, I came across the following, which is exactly my use case: https://stackoverflow.com/a/43298689/5526865 . I won't copy the code here, but just check that out.

Multiple outputs per input in Tensorflow

Is it possible to get the semantics of an unbounded arc in Tensorflow without directly enqueuing in the op itself?
For example, if I want to write an operation on that takes a scalar string my_string and "emits" tuples of ("string", num_occurrences_in_my_string), I have to resort to either of the following output options (as far as I know):
return the values necessary to construct a sparse Tensor
take a queue reference (of the correct type) and directly enqueue the input myself (like the tf.TextLineReader does)
As far as I can tell from the paper from Google on the Tensorflow "programming language", these are the only ways to accomplish it.
Is there a way in Tensorflow to emit an arbitrary number of output "rounds" per a given input besides the aforementioned workarounds?

How to effectively use knn in Stata

I have two questions with executing discrim knn in Stata.
1) How do you properly code the command? I've tried various versions, but seem to always get an error that there are too many variables specified.
The vector with the correct result is buy.
I am trying: discrim knn buy, group(train test) k(1)
2) My understanding with KNN was that factor variables (binary) were fine for using KNN, even encouraged. However I get the error message that factor variables and time-series operators not allowed.
Lastly, though I know this isn't the best space for this question, should each vector be normalized for knn? I've heard conflicting responses.
I'm guessing that the error you're getting is
group(): too many variables specified
This is because you can only group by 1 variable with knn. knn performs discriminant analysis based on a single grouping variable, in your case, distinguishing the training from the test. I imagine your train and test variables are binary, in which case using only one of the variables is enough, as they are merely logical opposites of each other. A single variable has enough information to distinguish the two groups.