Am running Python 3.8.10 in a 32-bit Windows 7 computer with only 2GB memory and no video card (not even an NVIDIA) - it's a two decade old netbook...
I editd the code below in hopes of finally giving up a result:
import numpy as np
from scipy import ndimage
database = """5 3 4 5 1 2
1 3 1 5 0 4
2 3 0 5 1 2
0 5 4 0 5 2
1 1 0 5 2 4
4 1 4 3 0 0
4 3 3 3 2 3
2 3 3 1 4 1
4 2 3 3 1 1
2 3 1 4 4 2
0 2 3 4 2 2
3 4 5 4 5 1
2 4 3 1 0 2
2 1 2 2 0 5
4 4 1 0 1 3
2 2 5 4 0 2
3 2 2 2 4 3
4 1 3 3 3 2
5 3 3 1 3 5
1 0 2 2 5 3
1 3 3 5 0 2
2 3 4 1 1 0
0 0 4 2 4 1
4 3 2 4 1 3
3 4 4 1 1 4
1 2 4 1 5 4
5 5 4 2 0 5
5 4 1 4 5 5
4 4 4 2 2 0
1 3 1 2 0 1
1 2 4 4 5 5
3 2 1 4 5 5
5 1 5 2 5 4
0 1 5 5 5 4
3 3 1 5 3 5
5 3 3 4 3 5
"""
def predict_next_string(database):
strings = np.array(database.split('\n'))
last_two_strings = ndimage.laplace(strings.astype(bool), mode='constant')
if len(last_two_strings) < 2:
print ("Not enough strings in the database,")
return
last_string = last_two_strings[-1]
last_string_numbers = [int(x) for x in last_string.split()]
predicted_string = ' '.join([str(x + 1) for x in last_string_numbers])
print("The predicted next string is", predicted_string)
predict_next_string(database)
As usual, it is meant to predict the next string of 6 numbers from 0 to 5.
This time, it showed up an error:
Traceback (most recent call last):
File "/home/main.py", line 65, in <module>
predict_next_string(database)
File "/home/main.py", line 46, in predict_next_string
last_two_strings = ndimage.laplace(strings.astype(bool), mode='constant')
ValueError: invalid literal for int() with base 10: '5 3 4 5 1 2'
Do I need to add in libraries like pytorch, keras, pandas, etc. to erase the error and finally yield the desired output?
If yes, what rewrites must I insert into the code and where exactly?
What I have tried:
I did some edits (way different from last time)
> had made a function call at the end of the code (thanks to the people who pointed that out)
> put the database portion at the top of the code
...but still an error.
Now am really unsure where to go from here.