I use tensorflow to implement why RNN will invalid syntax when initializing variables

I am a rookie. I just started to learn tensorflow,. When I used tensorflow to implement RNN, init = tf.global_variables_initializer () reported an error. I am so ignorant-- pray for God! Thank you!

    import tensorflow as tf
    from tensorflow.examples.tutorials.mnist import input_data
    
    mnist = input_data.read_data_sets("MNIST_data",one_hot=True)
    
    n_inputs = 28
    max_time = 28
    lstm_size = 100
    batch_size = 50
    n_batch = mnist.train.num_examples // batch_size
    n_class = 10 
    
    x= tf.placeholder(tf.float32,[None,784])
    y= tf.placeholder(tf.float32,[None,10])
    
    weight = tf.Variable(tf.truncated_normal([lstm_size,n_class],stddev=0.1))-sharp-sharp-sharp
    bias = tf.Variable(tf.constant(0.1,shape=[n_class]))
    
    def rnn(X,weight,bias):
        -sharpinputs = [batch_size,max_time,n_inputs]
    
        inputs = tf.reshape(X,[-1,max_time,n_inputs])
        lstm_cell = tf.contrib.rnn.BasicLSTMCell(lstm_size)
        -sharpfinal_state[0]cell_state
        -sharpfinal_state[1]hidden_state
        outputs,final_state = tf.nn.dynamic_rnn(lstm_cell,inputs,dtype=tf.float32)
        results = tf.nn.softmax(tf.matmul(final_state[1],weight) + bias)
        return results
    
    prediction = rnn(x,weight,bias)
    cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y,logits=prediction))
    train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
    
    correct_prediction = tf.equal(tf.argmax(prediction,1),tf.argmax(y,1))
    acc = tf.reduce_mean(tf.cast(correct_prediction,tf.float32)
    
--> init = tf.global_variables_initializer()
    
    with tf.Session() as sess:
        sess.run(init)
        for epoch in range(6):
            for batch in range(n_batch):
                batch_xs,batch_ys = mnist.train.next_batch(batch_size)
                sess.run(train_step,feed_dict={x:batch_xs,y:batch_ys})
                
            train_acc = sess.run(accuracy,feed_dict={x:mnist.train.images[:10000],y:mnist.train.labels[:10000]})
            test_acc = sess.run(accuracy,feed_dict={x:mnist.test.images,y:mnist.test.labels})
            print("Iter: " + str(i) + " , Train_acc: " + str(train_acc) + " , Test_acc" + str(test_acc))
    

error message is

  File "u8.py", line 47
    init = tf.global_variables_initializer()
       ^
SyntaxError: invalid syntax


Mar.03,2021

is careless, omitting one in the previous line of code)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3254a-2b652.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3254a-2b652.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?