Graduate School/Neural Network
Linear Classifier 02
- -
728x90
반응형
In [1]:
import numpy as np
import tensorflow as tf
import time
np.random.seed(101)
2022-10-12 17:13:46.461742: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
build your own data¶
x_train: [12, 4]
y_train: [12, ]
x_test: [4, 4]
y_test: [4, ]
[1, 0, 0, 0] --> 0
[0, 1, 0, 0] --> 0
[0, 0, 1, 0] --> 1
[0, 0, 0, 1] --> 1
In [2]:
x_train = np.zeros(shape=[12, 4], dtype=np.float32)
y_train = np.random.randint(0, 4, [12, ])
print(x_train)
print(y_train)
[[0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.]] [3 3 1 2 3 3 1 3 3 1 1 0]
In [3]:
x_train[np.arange(0, 12), y_train] = 1
print(x_train)
[[0. 0. 0. 1.] [0. 0. 0. 1.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.] [0. 0. 0. 1.] [0. 1. 0. 0.] [0. 0. 0. 1.] [0. 0. 0. 1.] [0. 1. 0. 0.] [0. 1. 0. 0.] [1. 0. 0. 0.]]
In [4]:
y_test = np.int32(np.arange(0, 4))
x_test = np.zeros(shape=[4, 4], dtype=np.float32)
x_test[np.arange(0, 4), y_test] = 1
y_train[y_train == 1] = 0
y_train[y_train > 0] = 1
y_test[y_test == 1] = 0
y_test[y_test > 0] = 1
print(x_test)
print(y_test)
[[1. 0. 0. 0.] [0. 1. 0. 0.] [0. 0. 1. 0.] [0. 0. 0. 1.]] [0 0 1 1]
Linear Classifier¶
$ f = W^T X + b $
In [5]:
class Linear:
def __init__(self, w_shape=[4, 2]):
self.w = np.random.random(size=w_shape)
self.w = np.float32(self.w)
self.b = np.random.random(size=[w_shape[1]])
self.b = np.float32(self.b)
self.w, self.b = tf.Variable(self.w), tf.Variable(self.b)
def forward(self, x):
z = tf.matmul(x, self.w)+self.b # z = w*x+b
return z
In [6]:
lin = Linear()
print(lin.w.shape)
print(lin.b.shape)
(4, 2) (2,)
2022-10-12 17:13:48.138135: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F AVX512_VNNI FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-10-12 17:13:48.628304: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 22077 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:65:00.0, compute capability: 8.6
In [7]:
z = lin.forward(x_train)
print(z.shape)
print(z)
(12, 2) tf.Tensor( [[1.1473757 1.0179554 ] [1.1473757 1.0179554 ] [1.6870271 0.4222926 ] [1.5197108 0.58448565] [1.1473757 1.0179554 ] [1.1473757 1.0179554 ] [1.6870271 0.4222926 ] [1.1473757 1.0179554 ] [1.1473757 1.0179554 ] [1.6870271 0.4222926 ] [1.6870271 0.4222926 ] [1.2724495 1.1259668 ]], shape=(12, 2), dtype=float32)
2022-10-12 17:13:49.799117: I tensorflow/stream_executor/cuda/cuda_blas.cc:1786] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
In [8]:
class Loss:
def __init__(self):
pass
def forward(self, x, y):
"""
x's shape = [N,2]
y's shape = [N,]
"""
# step-1: choose the true class score
# inputs: x [N,2], (y), outputs: x_true [N,]
# find: dx, upstream: dx_true
N = tf.shape(x)[0]
row_idx = tf.range(0, N)
row_col_idx = tf.transpose(tf.stack([row_idx, y]))
x_true = tf.gather_nd(x, indices=row_col_idx)
# step-2: find the score difference
# inputs: x [N,2], x_true [N,], outputs: diff [N,2]
# find: dx [N,2], dx_true [N,], upstream: ddiff [N,2]
diff = x-tf.expand_dims(x_true, axis=1)+1 #[N,2]
# step-3: clip the difference
# inputs: diff [N,2], outputs: clip_diff [N,2]
# find: ddiff [N,2], upstream: dclip_diff [N,2]
clip_diff = tf.where(diff<0.0, 0.0, diff) #[N,2]
# step-4: sum along the col axis
# inputs: clip_diff [N,2], outputs: diff_sum [N,]
# find: dclip_diff, upstream: ddiff_sum [N,]
diff_sum = tf.reduce_sum(clip_diff, axis=1) #[N,]
# step-5: find mean_loss
# inputs: diff_sum [N,] outputs: loss [1]
# find: ddiff_sum [N,] upstream: 1.0
loss = tf.reduce_mean(diff_sum) # 1
return loss
In [9]:
class Classifier:
def __init__(self, input_dim=4, n_class=2):
self.trainable_vars = []
# initialize all the layers
self.linear = Linear(w_shape=[input_dim, n_class])
# self.linear2 = Linear(~~) # !!! for Midterm-HW
self.trainable_vars.extend([self.linear.w, self.linear.b])
self.loss = Loss()
def forward(self, x, y):
# h = self.l1.f() # !!! for Midterm-HW
score = self.linear.forward(x)
loss = self.loss.forward(score, y)
return score, loss
#@tf.function
def update(self, x, y, step_size):
# step-1: update gradient
with tf.GradientTape() as tape:
score, loss = self.forward(x, y)
# step-2: find gradient
grads = tape.gradient(loss, self.trainable_vars)
# step-3: update variables
for i, vars in enumerate(self.trainable_vars):
self.trainable_vars[i].assign_sub(grads[i]*step_size)
return score, loss
def train(self, epoch=100, batch_size=4, step_size=0.1):
for ep in range(epoch):
# sample the batch from training data
idx = np.random.permutation(len(y_train))
batch_idx = np.arange(0, batch_size)
x = x_train[batch_idx]
y = y_train[batch_idx]
start = time.perf_counter()
score, loss = c.update(x, y, step_size)
print("elapsed time:", time.perf_counter()-start)
test_score, test_loss = c.forward(x_test, y_test)
print(ep, loss, test_loss)
In [10]:
c = Classifier()
score, loss = c.forward(x_test, y_test)
print(score)
print(loss)
tf.Tensor( [[0.27052885 1.5978663 ] [0.9159602 1.2705567 ] [0.87227374 1.5121853 ] [0.23545197 1.1321871 ]], shape=(4, 2), dtype=float32) tf.Tensor(2.0363219, shape=(), dtype=float32)
In [11]:
c.backward()
print(c.linear.dw)
print(c.linear.db)
print()
print(c.linear.w)
print(c.linear.b)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [11], in <cell line: 1>() ----> 1 c.backward() 2 print(c.linear.dw) 3 print(c.linear.db) AttributeError: 'Classifier' object has no attribute 'backward'
In [12]:
c = Classifier()
c.train()
print()
print(c.linear.w)
print(c.linear.b)
elapsed time: 0.018572985994978808 0 tf.Tensor(2.3056033, shape=(), dtype=float32) tf.Tensor(1.9540684, shape=(), dtype=float32) elapsed time: 0.004832623002585024 1 tf.Tensor(2.1806033, shape=(), dtype=float32) tf.Tensor(1.9040685, shape=(), dtype=float32) elapsed time: 0.003910038998583332 2 tf.Tensor(2.0556033, shape=(), dtype=float32) tf.Tensor(1.8540685, shape=(), dtype=float32) elapsed time: 0.003927106008632109 3 tf.Tensor(1.9306033, shape=(), dtype=float32) tf.Tensor(1.8040686, shape=(), dtype=float32) elapsed time: 0.0035564119898481295 4 tf.Tensor(1.8056033, shape=(), dtype=float32) tf.Tensor(1.7540685, shape=(), dtype=float32) elapsed time: 0.004156499009695835 5 tf.Tensor(1.6806033, shape=(), dtype=float32) tf.Tensor(1.7040684, shape=(), dtype=float32) elapsed time: 0.004149676999077201 6 tf.Tensor(1.5556033, shape=(), dtype=float32) tf.Tensor(1.6540685, shape=(), dtype=float32) elapsed time: 0.0038468999991891906 7 tf.Tensor(1.4306033, shape=(), dtype=float32) tf.Tensor(1.6040685, shape=(), dtype=float32) elapsed time: 0.004040008003357798 8 tf.Tensor(1.3056033, shape=(), dtype=float32) tf.Tensor(1.590314, shape=(), dtype=float32) elapsed time: 0.0036148369981674477 9 tf.Tensor(1.2530942, shape=(), dtype=float32) tf.Tensor(1.565314, shape=(), dtype=float32) elapsed time: 0.0034424990008119494 10 tf.Tensor(1.2280942, shape=(), dtype=float32) tf.Tensor(1.540314, shape=(), dtype=float32) elapsed time: 0.0034415849950164557 11 tf.Tensor(1.2030942, shape=(), dtype=float32) tf.Tensor(1.5153141, shape=(), dtype=float32) elapsed time: 0.004813015999388881 12 tf.Tensor(1.1780941, shape=(), dtype=float32) tf.Tensor(1.490314, shape=(), dtype=float32) elapsed time: 0.0034888890077127144 13 tf.Tensor(1.1530943, shape=(), dtype=float32) tf.Tensor(1.4653141, shape=(), dtype=float32) elapsed time: 0.0036784510011784732 14 tf.Tensor(1.1280942, shape=(), dtype=float32) tf.Tensor(1.440314, shape=(), dtype=float32) elapsed time: 0.004526581993559375 15 tf.Tensor(1.1030943, shape=(), dtype=float32) tf.Tensor(1.4153141, shape=(), dtype=float32) elapsed time: 0.003571542998543009 16 tf.Tensor(1.0780942, shape=(), dtype=float32) tf.Tensor(1.3991944, shape=(), dtype=float32) elapsed time: 0.0036820910027017817 17 tf.Tensor(1.0619745, shape=(), dtype=float32) tf.Tensor(1.365314, shape=(), dtype=float32) elapsed time: 0.004570349003188312 18 tf.Tensor(1.0405943, shape=(), dtype=float32) tf.Tensor(1.3491943, shape=(), dtype=float32) elapsed time: 0.0035550530010368675 19 tf.Tensor(1.0244746, shape=(), dtype=float32) tf.Tensor(1.3158395, shape=(), dtype=float32) elapsed time: 0.0035826819948852062 20 tf.Tensor(1.0036197, shape=(), dtype=float32) tf.Tensor(1.3366944, shape=(), dtype=float32) elapsed time: 0.004388304994790815 21 tf.Tensor(1.0119746, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.011375334986951202 22 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.007214794997707941 23 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.004892623008345254 24 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0036851299955742434 25 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.004139355994993821 26 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0037178380007389933 27 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003354561995365657 28 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0048422859981656075 29 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0037096900050528347 30 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003924511998775415 31 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003311285996460356 32 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003709812997840345 33 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034033980045933276 34 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.004060082006617449 35 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033860389958135784 36 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003370067002833821 37 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003441174005274661 38 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003392280006664805 39 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033706929971231148 40 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003346491008414887 41 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003221524995751679 42 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003275364011642523 43 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033550590014783666 44 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034164410026278347 45 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0036410130123840645 46 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003709328011609614 47 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003381033006007783 48 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003199318001861684 49 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033363009861204773 50 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033813740010373294 51 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033603470074012876 52 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033710790012264624 53 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0032895360054681078 54 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003377729997737333 55 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033488720073364675 56 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003394882005522959 57 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003418517007958144 58 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0032874960015760735 59 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.00341326100169681 60 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033381559915142134 61 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033610799873713404 62 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003192766002030112 63 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003988696000305936 64 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033418759994674474 65 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033429580071242526 66 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033927219919860363 67 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.004072368989000097 68 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033764280087780207 69 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033992940007010475 70 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003387089993339032 71 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003362792995176278 72 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033580289891688153 73 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003394972998648882 74 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003354651009431109 75 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034587559930514544 76 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003605453995987773 77 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034915349970106035 78 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003331214000354521 79 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034436429996276274 80 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.004745981001178734 81 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003351507999468595 82 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003318534989375621 83 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003348024998558685 84 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0032951580069493502 85 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033323440002277493 86 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.00338175700744614 87 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003405676005058922 88 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003254939991165884 89 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033738490019459277 90 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003313199005788192 91 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003377936009201221 92 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.00339496300148312 93 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003324321995023638 94 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003353926003910601 95 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0032842490036273375 96 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0033410870091756806 97 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.0034271019976586103 98 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) elapsed time: 0.003910679995897226 99 tf.Tensor(1.0, shape=(), dtype=float32) tf.Tensor(1.3122199, shape=(), dtype=float32) <tf.Variable 'Variable:0' shape=(4, 2) dtype=float32, numpy= array([[ 0.5206654 , 0.57878953], [ 1.2598186 , 0.01696173], [ 0.4381539 , 1.2829198 ], [-0.04700221, 0.80722445]], dtype=float32)> <tf.Variable 'Variable:0' shape=(2,) dtype=float32, numpy=array([0.55287653, 0.7436317 ], dtype=float32)>
728x90
반응형
'Graduate School > Neural Network' 카테고리의 다른 글
LSTM을 이용한 주식 가격 예측 (6) | 2024.09.10 |
---|---|
Face Recognition (0) | 2024.09.10 |
Image Prediction (0) | 2024.09.10 |
Linear Classifier 01 (0) | 2024.09.10 |
Contents
소중한 공감 감사합니다