V
V
Voprosium2020-10-04 13:07:15
Python
Voprosium, 2020-10-04 13:07:15

How to use a neural network with str?

Hello everyone, how to use a neural network in Python not with numbers but with strings?

The code
import numpy as np


def sigmoid(x):
  return 1 / (1 + np.exp(-x))


training_input = np.array()

training_output = np.array().T

np.random.seed(1)

synaptic_weights = 2 * np.random.random((3, 1)) - 1

print("Веса до обучения: ")
print(synaptic_weights)

for i in range(20000):
  input_layer = training_input
  outputs = sigmoid(np.dot(input_layer, synaptic_weights))

  err = training_output - outputs
  adjustments = np.dot(input_layer.T, err * (outputs * (1 - outputs)))
  synaptic_weights += adjustments
  

new = np.array([1, 1, 0])
output = sigmoid(np.dot(new, synaptic_weights))

print("Ответ: " + output)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2020-10-04
@Voprosium

Convert str to float.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question