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
import numpy as np | |
# Initialize the generating vector | |
x = np.array([1, 2, 3, 4, 5]) | |
y = np.array([5, 4, 3, 2, 1]) | |
# Initialize the permutation matrix | |
P = np.array([ | |
[0, 0, 0, 0, 1], | |
[1, 0, 0, 0, 0], | |
[0, 1, 0, 0, 0], |
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
from functools import reduce | |
from typing import Iterable, Dict, List, Union, Optional | |
from collections import Counter | |
import numpy as np | |
from data_provider import get_talks | |
class TokenizedDocument(Counter): |
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 SomeClass: | |
class single_execution: | |
"""Compute property only once and cache the result for further access. | |
When the property is first accessed, the result is computed, and the | |
attribute on the instance is replaced with the result. This is | |
essentially a single execution lazy property. | |
""" | |
def __init__(self, method): | |
self.__method = method | |
self.__attribute_name = method.__name__ |
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
import numpy as np | |
def entropy(p): | |
"""Compute the Shannon entropy of a distribution. | |
The Shannon entropy is defined as follows | |
:math:`\sum_x p(x_i) * \log p(x_i)`. | |
Parameters |
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
# Solution found here: https://github.com/fchollet/keras/issues/4044 | |
import h5py | |
f = h5py.File('model_file.h5', 'r+') | |
del f['optimizer_weights'] | |
f.close() |
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
Moodle prepend lang tags where any translations are needed. | |
Long syntax: | |
Find: | |
(<span lang="es") | |
Replace: | |
<span lang="en" class="multilang"> English version<\/span><span lang="sl" class="multilang"> Slovenska verzija<\/span>$1 | |
Short syntax: | |
Find: |
NewerOlder