构建TensorFlow图表低级别

时间:2018-02-10 10:11:32

标签: python tensorflow neural-network low-level

我的Graph是一个Links数组,其中Link是:

class Link:
     from_node_id
     to_node_id
     weight

我想从这个看起来像神经网络的结构中构建 tf.Graph Graph (tf.Operation)中的每个节点将在输入链接权重和来自进入该节点的其他节点的输出值之间进行点积,然后向前传递计算值。

我是TF的新手,不知道最好的方法是什么,所以欢迎任何帮助。

编辑: 我需要的伪代码和Python代码的混合:

for link in links:

    if not exists link.to_node_id:
        create new "node_id" Node
    if not exists link.from_node_id:
        create new "node_from" Node

    add "node_from" to inputs of "node_to" 

    # weights for node
    # creates new variable or returns one already created
    w = [v for v in tf.global_variables() if v.name == "Weight_" + link.to_node_id + ":0"][0]
   add link.weight to weights

0 个答案:

没有答案