模块 'tensorboard.summary._tf.summary' 没有属性 'FileWriter'

module 'tensorboard.summary._tf.summary' has no attribute 'FileWriter'

为什么每次我尝试 运行 我的 MCP 神经元时,张量流都会抛出这个异常“模块 'tensorboard.summary._tf.summary' 没有属性 'FileWriter'”,我该如何解决手头的问题?我在堆栈上进行了搜索,但找不到适合我的问题的任何解决方案。谁能帮帮我。

# McCulloch Pitt Neuron built with Tensorflow and represented with
# Tensorboard


import tensorflow as tf
import numpy as np
import os

PATH = os.getcwd()

LOG_DIR = PATH+ '/output/'
tf.compat.v1.disable_eager_execution()


# 1.Configuration to optimize CPU performance by defining
#   thread pools. For this example 4 is enough. A variable
#   replace the constant
config = tf.compat.v1.ConfigProto(
    inter_op_parallelism_threads=4,
    intra_op_parallelism_threads=4
)

# 2.Defining the x values, their w weights,the b bias,y weight calculation
#   and the s sigmoid activation function

x = tf.compat.v1.placeholder(tf.float32, shape=(1, 5), name='x')
w = tf.compat.v1.placeholder(tf.float32, shape=(5, 1), name='w')
b = tf.compat.v1.placeholder(tf.float32, shape=(1), name='b')
y = tf.matmul(x, w) + b
s = tf.nn.sigmoid(y)


# 3.Starting a session providing constants as weight inputs
#   The Perceptron,a neuron that can learn its weights, will provide  with our present day
#   automatic weight calculations
with tf.compat.v1.Session(config=config) as tfs:
    tfs.run(tf.compat.v1.global_variables_initializer())
    
    w_t = [[.1, .7, .75, .60, .20]]
    x_1 = [[10, 2, 1., 6., 2.]]
    b_1 = [1]
    w_1 = np.transpose(w_t)
    
    value = tfs.run(s, 
        feed_dict={
            x: x_1, 
            w: w_1,
            b: b_1
        }
    )
    
print ('value for threshold calculation',value)
print ('Availability of lx',1-value)
         
  
#___________Tensorboard________________________

#with tf.Session() as sess:

Writer = tf.summary.FileWriter(LOG_DIR, tfs.graph)
Writer.close()


def launchTensorBoard():
    import os
    os.system('tensorboard --logdir='+LOG_DIR)
    return

import threading
t = threading.Thread(target=launchTensorBoard, args=([]))
t.start()

tfs.close()

尝试使用:

Writer = tf.summary.create_file_writer(LOG_DIR)

或者,如果你还想传递图表,请执行以下操作:

Writer = tf.compat.v1.summary.FileWriter(LOG_DIR, tfs.graph)

有关详细信息,请参阅 docs