0
Context
I’m replicating an algorithm of neural network of the kind Single Layer Perceptron (simpler neural network model). I used the library Tensorflow and wrote the code based on the documentation tutorial (https://www.tutorialspoint.com/tensorflow/tensorflow_single_layer_perceptron.htm).
But, the following error occurred and I don’t know how to fix.
Attributeerror Traceback (Most recent call last) in 1 for epoch in range(training_epochs): 2 avg_cost = 0. -----> 3 total_batch = int(mnist.train.num_examples/batch_size)
Attributeerror: str Object has no attribute 'Train'
Code:
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
mnist = ("_dados/train150_mucuri.txt")
#Parâmetros
learning_rate = 0.01
training_epochs = 25
batch_size = 100
display_step = 1
#Dados de entrada do gráfico
x = tf.placeholder("float", [None, 302500]) # dados da velocidade versus tempo 550x550 = 302.500
y = tf.placeholder("float", [None, 10]) # 0-9 dígitos de reconhecimento => 10 classes
# Criar o modelo
# Definir os pesos do modelo
W = tf.Variable(tf.zeros([302500,10]))
b = tf.Variable(tf.zeros([10]))
# Modelo de construção
activation = tf.nn.softmax(tf.matmul(x, W) + b) # Softmax - função de soma
# Minimiza o erro usando entropia cruzada
cross_entropy = y*tf.log(activation)
cost = tf.reduce_mean(-tf.reduce_sum(cross_entropy, reduction_indices = 1))
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
#Configurações de plotagem
avg_set = []
epoch_set = []
# Inicializando as variáveis
init = tf.global_variables_initializer()
#Iniciar o gráfico
with tf.Session() as sess:
sess.run(init)
#Ciclo de Treinamento
for epoch in range(training_epochs):
avg_cost = 0.
total_batch = int(mnist.train.num_examples/batch_size)