My goal is to build a neural net that can find patterns between a hash and a word on it's own. So that it returns the word of any hash that I will input.
Unfortunatally my skill in the area of neural net isn´t advanced, and I want to use this project to learn more. So I use a German dictionary and encode it via
one_hot encoding. Then I generate the
sha256 value of every word inside (before I have done this I cleaned the file and wrote every word in another line) it. So I got an big array with the shape of 20000x20000 for the words and another for the hashs.
So then I used the a example of the Keras homepage for
binary classification because the one_hot values are represented by ones and zeros.
So if I want to predict a hashs I get these error:
Error when checking : expected dense_1_input to have shape (20000,) but got array with shape (1,). So I don't know if this model is working for my problem but I couldn't convert one hash into a size of 20000x20000. (The hash will
one_hot encoded for that prediction). So how could I get it to accept different shaped hashs/one hash only?
Is there a way to train the model with each hash after another for example with a for loop?!
EDIT: So I figured out that I can convert a list of characters into a numpy.array with 2 dimensions. So I
hot_encoded every character and create a list of them, these list I passed inside the
np.array(words,ndim=2). So this I have done for my hashs aswell. Then after I run the code I got this error:
ValueError: setting an array element with a sequence So I tried to reshape the array with the
.reshape(20000) command but nothing chaged. So what to do with that? EDIT2: I figured out now that the problem is that
enhot_encoding generates diffrent sized "arrays" for each word, and if I fill this into a real array and this into a neuronal net it have to return this error. But still the question is: How to convert single words and hashs to a format that I can train a neuronal net with and get usefull output so I can enter any hash and it should return some kind of word(lable). If you need the actual code please inform me and I will upload it`s current state.
model = Sequential() model.add(Dense(64, input_shape=20000, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(64, activation='relu')) model.add(Dense(units=64, activation="relu")) model.add(Dropout(0.5)) model.add(Dense(19957, activation='sigmoid')) model.compile(loss='binary_crossentropy',optimizer='rmsprop', metrics=['accuracy']) print("Fitting data...") model.fit(test_hashs,test_words ,epochs=10,batch_size=128, verbose=1) train_y=input("Input a hash that is not contained in the training data: ") #train_x=pd.Series(hashlib.sha256(str.encode(train_y)).hexdigest()) train_y=pd.Series(train_y) #test_x=pd.get_dummies(train_x) test_y=pd.get_dummies(train_y) model.save("first_test") print(model.evaluate(test_y)) #score=model.evaluate(test_x, test_y, batch_size=128,) print("Score: "+score) prediction=model.predict(test_x,verbose=1) for i in prediction: print(i)