Edited, memorised or added to reading queue

on 28-Apr-2024 (Sun)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 7624069090572

Tags
#tensorflow #tensorflow-certificate
Question

from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
import numpy as np

model = Sequential(Dense(1, input_shape=[1]))
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([1,5,12,-1,10], dtype=float)
ys = np.array([5,13,27,1,23], dtype=float)
model.fit([...], epochs=500)
model.predict(x=[15])

Answer
xs, ys

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Tensorflow basics - typical flow of model building
= Sequential(Dense(1, input_shape=[1])) model.compile(optimizer='sgd', loss='mean_squared_error') xs = np.array([1,5,12,-1,10], dtype=float) ys = np.array([5,13,27,1,23], dtype=float) model.fit(<span>xs, ys, epochs=500) model.predict(x=[15]) <span>







Flashcard 7624072236300

Tags
#tensorflow #tensorflow-certificate
Question

from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
import numpy as np

model = Sequential(Dense(1, [...]=[1]))
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([1,5,12,-1,10], dtype=float)
ys = np.array([5,13,27,1,23], dtype=float)
model.fit(xs, ys, epochs=500)
model.predict(x=[15])

Answer
input_shape

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Tensorflow basics - typical flow of model building
from tensorflow.keras import Sequential from tensorflow.keras.layers import Dense import numpy as np model = Sequential(Dense(1, input_shape=[1])) model.compile(optimizer='sgd', loss='mean_squared_error') xs = np.array([1,5,12,-1,10], dtype=float) ys = np.array([5,13,27,1,23], dtype=float) model.fit(xs, ys, epochs=500) model







Flashcard 7624088227084

Tags
#tensorflow #tensorflow-certificate
Question

import tensorflow as tf

#stop training after reaching accuract of 0.99
class MyCallback(tf.keras.callbacks.Callback):
  def on_epoch_end(self, epoch, logs={}):
    if logs.[...]('accuracy')>=0.99:
      print('\nAccuracy 0.99 achieved')
      self.model.stop_training = True

Answer
get

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Tensorflow - callbacks
import tensorflow as tf #stop training after reaching accuract of 0.99 class MyCallback(tf.keras.callbacks.Callback): def on_epoch_end(self, epoch, logs={}): if logs.get('accuracy')>=0.99: print('\nAccuracy 0.99 achieved') self.model.stop_training = True







Flashcard 7625619410188

Tags
#tensorflow #tensorflow-certificate
Question
y_test.shape, y_pred.shape, y_pred.[...]((10, )).shape, tf.squeeze(y_pred).shape


(TensorShape([10]), (10, 1), (10,), TensorShape([10]))

Answer
reshape

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Different shapes of the tensors
y_test.shape, y_pred.shape, y_pred.reshape((10, )).shape, tf.squeeze(y_pred).shape (TensorShape([10]), (10, 1), (10,), TensorShape([10]))







Flashcard 7625628323084

Tags
#tensorflow #tensorflow-certificate
Question
# Calculate MSE "by hand" in steps - identify functions

abs_err = [...](tf.subtract(tf.cast(y_test, dtype=tf.float32), tf.squeeze(y_pred)))
sq_abs_err = tf.multiply(abs_err, abs_err)
sq_abs_err
tf.math.reduce_mean(sq_abs_err)



<tf.Tensor: shape=(), dtype=float32, numpy=155.11417>

Answer
tf.abs

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Calculate MSE &quot;by hand&quot; in steps - identify functions
# Calculate MSE "by hand" in steps - identify functions abs_err = tf.abs(tf.subtract(tf.cast(y_test, dtype=tf.float32), tf.squeeze(y_pred))) sq_abs_err = tf.multiply(abs_err, abs_err) sq_abs_err tf.math.reduce_mean(sq_abs_err) <tf.Tensor: shape=(), dtype=







Flashcard 7625643265292

Tags
#has-images #tensorflow #tensorflow-certificate
[unknown IMAGE 7625638546700]
Question
[...](model_2, show_shapes=True)

Answer
plot_model

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Visualize model
plot_model(model_2, show_shapes=True)







Flashcard 7625690713356

Tags
#tensorflow #tensorflow-certificate
Question
tf.ones([10, 7])


<tf.Tensor: shape=(10, 7), dtype=float32, numpy=
array([[1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1.]], dtype=[...])>

Answer
float32

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Open it
, 1.], [1., 1., 1., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.], [1., 1., 1., 1., 1., 1., 1.]], dtype=<span>float32)> <span>