첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ 단일 입력 뉴런을 만드는 방법을 보여준다.

 

▶ 예제 코드 (PY)

import tensorflow as tf

weightVariable = tf.Variable(1.0, name = "weight")

inputValueTensor = tf.constant(0.5, name = "inputValue")

expectedOuptutValueTensor = tf.constant(0.0, name = "expectedOutputValue")

actualOutputValueTensor = tf.multiply(inputValueTensor, weightVariable, "actualOutputValue")

lossFunctionTensor = tf.pow(expectedOuptutValueTensor - actualOutputValueTensor, 2, name = "lossFunction")

optimizerOperation = tf.train.GradientDescentOptimizer(0.025).minimize(lossFunctionTensor)

for value in [inputValueTensor, weightVariable, expectedOuptutValueTensor, actualOutputValueTensor, lossFunctionTensor]:
    tf.summary.scalar(value.op.name, value)

symmaryTensor = tf.summary.merge_all()

with tf.Session() as session:
    summaryFileWriter = tf.summary.FileWriter("c:/SummaryLog", session.graph)
    session.run(tf.global_variables_initializer())
    for i in range(100):
        summaryFileWriter.add_summary(session.run(symmaryTensor), i)
        session.run(optimizerOperation)
728x90
그리드형(광고전용)
Posted by icodebroker
,