import random
import numpy as np
import tensorflow as tf
from keras import layers
from keras import models
from keras import optimizers
filepath = tf.keras.utils.get_file('shakespeare.txt',
'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt')
text = open(filepath, 'rb').read().decode(encoding='utf-8').lower()
text = text[300000:800000]
characters = sorted(set(text))
char_to_index = dict((c, i) for i, c in enumerate(characters))
index_to_char = dict((i, c) for i, c in enumerate(characters))
SEQ_LENGTH = 40
STEP_SIZE = 3
sentences = []
next_characters = []
for i in range(0, len(text) - SEQ_LENGTH, STEP_SIZE):
sentences.append(text[i: i + SEQ_LENGTH])
next_characters.append(text[i: i + SEQ_LENGTH])
x = np.zeros((len(sentences), SEQ_LENGTH, len(characters)), dtype=np.bool_)
y = np.zeros((len(sentences), len(characters)), dtype=np.bool_)
for i, sentence in enumerate(sentences):
for t, character in enumerate(sentence):
x[i, t, char_to_index[character]] = 1
y[i, char_to_index[next_characters[i]]] = 1
model = models.Sequential()
model.add(layers.LSTM(128, input_shape=(SEQ_LENGTH, len(characters))))
model.add(layers.Dense(len(characters)))
model.add(layers.Activation('softmax'))
model.compile(loss='categorical_crossentropy', optimizer=optimizers.RMSprop(lr=0.01))
model.fit(x, y, batch_size=256, epochs=4)
model.save('textgenerator.model')
When I am running this code, it is giving me the fallowing error: “Process finished with exit code 132 (interrupted by signal 4: SIGILL).”
I was fallowing the tutorial by NeuralNine: https://www.youtube.com/watch?v=QM5XDc4NQJo&list=PL7yh-TELLS1G9mmnBN3ZSY8hYgJ5kBOg-
What neural Nine got
New contributor
KNine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.