I'm wondering what tensor flow uses to perform row reduction. Specifically when I call tf.linalg.inv what algorithm runs? Tensorflow is open source so I figured that it would be easy enough to find but I find myself a little lost in the code base. If I could just get a pointer to the implementation of the aforementioned function that would be great. If there is a name for the Gauss Jordan elimination implementation they used that would be even better.
https://github.com/tensorflow/tensorflow
The op uses LU decomposition with partial pivoting to compute the inverses.
For more insighton tf.linalg.inv algorithm please refer to this link: https://www.tensorflow.org/api_docs/python/tf/linalg/inv
-
If you wish to experiment with something similar please refer to this stackoverflow link here
After I have read about selection sort and tried to write the code for it in java (Why doesn't my selection sort algorithm do what it's supposed to (java)?), and then looked at our script, I got confused. The pseudo-code for selection sort seems wrong or rather incomplete for me. It looks more similar to bubble sort than selection sort pseudo-code.
I mean, where is the important part of the code where you look for the smallest value of the array and put it to the beginning and repeat that process?
I hope this is the correct section to ask, and if not, please tell me where I can ask it (I would delete that question immediately). But it's very important for me to understand what has been written there and your opinion about it.
(I'm especially very curious and afraid how I shall write pseudo code for selection sort in an exam, if asked.)
I would like to get some helpful instructions about how to use the Q-learning algorithm with function approximation. For the basic Q-learning algorithm I have found examples and I think I did understand it. In case of using function approximation I get into trouble. Can somebody give me an explanation through a short example how it works?
What I know:
Istead of using matrix for Q-values we use features and parameters.
Make approximation with the linear combination of feauters and parameters.
Update the parameters.
I have checked this paper: Q-learning with function approximation
But I cant find any useful tutorial how to use it.
Thanks for help!
To my view, this is one of the best references to start with. It is well written with several pseudo-code examples. In your case, you can simplify the algorithms by ignoring eligibility traces.
Also, to my experience and depending on your use case, Q-Learning might not work very well (sometimes it needs huge amounts of experience data). You can try Fitted-Q value for example, which is a batch algorithm.
Why would you choose bubble sort over other sorting algorithms?
You wouldn't.
Owen Astrachan of Duke University once wrote a research paper tracing the history of bubble sort (Bubble Sort: An Archaeological Algorithmic Analysis) and quotes CS legend Don Knuth as saying
In short, the bubble sort seems to have nothing to recommend it, except a catchy name
and the fact that it leads to some interesting theoretical problems.
The paper concludes with
In this paper we have investigated the origins of bubble sort and its enduring popularity despite warnings against its use by many experts. We confirm the warnings by analyzing its complexity both in coding and runtime.
Bubble sort is slower than the other O(n2) sorts; it's about four times as slow as insertion sort and twice as slow as selection sort. It does have good best-case behavior (if you include a check for no swaps), but so does Insertion Sort: just one pass over an already-sorted array.
Bubble Sort is impractically slow on almost all real data sets. Any good implementation of quicksort, heapsort, or mergesort is likely to outperform it by a wide margin. Recursive sorts that use a simpler sorting algorithm for small-enough base-cases use Insertion Sort, not Bubble Sort.
Also, the President of the United States says you shouldn't use it.
Related: Why bubble sort is not efficient? has some more details.
There's one circumstance in which bubble sort is optimal, but it's one that can only really occur with ancient hardware (basically, something like a drum memory with two heads, where you can only read through the data in order, and only work with two data items that are directly next to each other on the drum).
Other than that, it's utterly useless, IMO. Even the excuse of getting something up and running quickly is nonsense, at least in my opinion. A selection sort or insertion sort is easier to write and/or understand.
You would implement bubble sort if you needed to create a web page showing an animation of bubble sort in action.
When all of the following conditions are true
Implementing speed is way more important than execution speed (probability <1%)
Bubble sort is the only sorting algorithm you remember from university class (probability 99%)
You have no sorting library at hand (probability <1%)
You don't have access to Google (probability <1%)
That would be less than 0,000099 % chance that you need to implement bubble sort, that is less than one in a million.
If your data is on a tape that is fast to read forward, slow to seek backward, and fast to rewind (or is a loop so it doesn't need rewinding), then bubblesort will perform quite well.
I suspect a trick question. No one would choose bubble sort over other sorting algorithms in the general case. The only time it really makes any sense is when you're virtually certain that the input is (nearly) sorted already.
Bubble sort is easy to implement. While the 'standard' implementation has poor performance, there is a very simple optimization which makes it a strong contender compared to many other simple algorithms. Google 'combsort', and see the magic of a few well placed lines. Quicksort still outperforms this, but is less obvious to implement and needs a language that supports recursive implementations.
I can think of a few reasons for bubble sort:
It's a basic elementary sort. They're great for beginner programmers learning the if, for, and while statements.
I can picture some free time for a programmer to experiment on how all the sorts work. What better to start with at the top with than the bubble sort (yes, this does demean its rank, but who doesn't think 'bubble sort' if someone says 'sorting algorithms').
Very easy to remember and work with for any algorithm.
When I was starting on linked lists, bubble sort helped me understand how all the nodes worked well with each other.
Now I'm feeling like a lame commercial advertising about bubble sort so I'll be quiet now.
I suppose you would choose bubble sort if you needed a sorting algorithm which was guaranteed to be stable and had a very small memory footprint. Basically, if memory is really scarce in the system (and performance isn't a concern) then it would work, and would be easily understood by anybody supporting the code. It also helps if you know ahead of time that the values are mostly sorted already.
Even in that case, insertion sort would probably be better.
And if it's a trick question, next time suggest Bogosort as an alternative. After all, if they're looking for bad sorting, that's the way to go.
It's useful for "Baby's First Sort" types of exercises in school because it's easy to explain how it works and it's easy to implement. Once you've written it, and maybe run it once, delete it and never think of it again.
You might use Bubblesort if you just wanted to try something quickly. If, for instance, you are in a new environment and you are playing around with a new idea, you can quickly throw in a bubble sort in very little time. It might take you much longer to remember and write a different sort and debug it and you still might not get it right. If your experiment works out and you need to use the code for something real, then you can spend the time to get it right.
No sense putting a lot of effort into the sort algorithm if you are just prototyping.
When demonstrating with a concrete example how not to implement a sort routine.
Because your other sorting algorithm is Monkey Sort? ;)
Seriously though, bubble sort is mainly a sorting algorithm for educational reasons and has no practical value.
When the array is already "almost" sorted or you have few additions into an already sorted-list, you can use bubble sort to resort it. Bubble sort usually works for small data-sets.
Greetings, I am looking for the pseudo code for "open", "chaining" abd "multiple hashing" algorithms. Yes I have been searching for a good amount of time at google but I wasn't able to get something good.
If you have a link to share, I will be greatful
regards
This hash table tutorial has examples of open and chaining collision resolution.
Bob Jenkins' Web Site has further examples of hash tables, perfect hashes and efficient hash functions.
I haven't found a satisfying explanation of multiple hashing (specifically why combining two different 32 bit hashes is considered better than a smooth 64 bit hash)
http://en.wikipedia.org/wiki/Cryptographic_hash_function
And from there:
http://en.wikipedia.org/wiki/MD5#Pseudocode
http://en.wikipedia.org/wiki/SHA_hash_functions#Examples_and_pseudocode
etc.