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
# StackOverflow question: https://stackoverflow.com/questions/51123481/how-to-build-a-language-model-using-lstm-that-assigns-probability-of-occurence-f | |
from keras.preprocessing.text import Tokenizer | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.layers import Embedding, LSTM, Dense | |
from keras.models import Sequential | |
import keras | |
import numpy as np | |
def prepare_sentence(seq, maxlen): |
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
# StackOverflow question: https://stackoverflow.com/questions/53105294/implementing-a-batch-dependent-loss-in-keras | |
from keras.utils import Sequence | |
from keras.models import Model | |
from keras.layers import Input, Dense | |
import keras.backend as K | |
import numpy as np | |
# Constants | |
input_dim = 64 # digits.data.shape[1] | |
dataset = np.random.rand(1000, input_dim) # TODO: replace with digits.data |
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
# StackOverflow question: https://stackoverflow.com/questions/51123481/how-to-build-a-language-model-using-lstm-that-assigns-probability-of-occurence-f | |
from keras.preprocessing.text import Tokenizer | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.layers import Embedding, LSTM, Dense | |
from keras.models import Sequential | |
import numpy as np | |
def prepare_sentence(seq, maxlen): | |
# Pads seq and slides windows |