mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
24 lines
311 B
Python
24 lines
311 B
Python
import numpy as np
|
|
import tensorflow as tf
|
|
|
|
W = tf.Variable(tf.ones(shape=(2, 2)), name="W")
|
|
b = tf.Variable(tf.zeros(shape=(2)), name="b")
|
|
|
|
W.assign(np.mat([
|
|
[1, 2],
|
|
[3, 4]
|
|
]))
|
|
|
|
b.assign([
|
|
1, 2
|
|
])
|
|
|
|
|
|
@tf.function
|
|
def forward(x):
|
|
return W * x + b
|
|
|
|
|
|
result = forward([1, 0])
|
|
print(result.numpy())
|