This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MaxHeap: | |
| @staticmethod | |
| def _swap(_list, idx1, idx2): | |
| _list[idx1], _list[idx2] = _list[idx2], _list[idx1] | |
| @staticmethod | |
| def _getParent(idx): | |
| return ((idx+1)//2) - 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fcn = FCN(10, 1) | |
| fcn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FCN(nn.Module): | |
| def __init__(self, input_dims, output_dims): | |
| super(FCN, self).__init__() | |
| self.model = nn.Sequential( | |
| nn.Linear(input_dims, 5), | |
| nn.LeakyReLU(), | |
| nn.Linear(5, output_dims), | |
| nn.Sigmoid() | |
| ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def quicksort(arr): | |
| if len(arr) == 1: | |
| return arr | |
| if len(arr) == 0: | |
| return [] | |
| pivot = arr[-1] | |
| left = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mergesort(array): | |
| left = array[:len(array)//2] | |
| right = array[len(array)//2:] | |
| left = mergesort(left) if len(left) >= 2 else left | |
| right = mergesort(right) if len(right) >= 2 else right |