You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The provided solution in the course for the mentioned video section 2: Neural Network Calssiifcation in TensorFlow doesn't work for some reason. So I figured out this solution instead:
# Set random seed
tf.random.set_seed(42)
# Create some regression data
X_regression = np.arange(0, 1000, 5)
y_regression = np.arange(100, 1100, 5) # y = X + 100
# Split it into training and test sets
X_reg_train = X_regression[:150]
X_reg_test = X_regression[150:]
y_reg_train = y_regression[:150]
y_reg_test = y_regression[150:]
# Create a simple neural network model
model = tf.keras.Sequential([
tf.keras.layers.Input(shape=(1,)), # Input layer with 1 feature
tf.keras.layers.Dense(64, activation='relu'), # Hidden layer with 64 units and ReLU activation
tf.keras.layers.Dense(1) # Output layer with 1 unit (regression)
])
# Compile the model
model.compile(optimizer='adam', loss='mean_squared_error')
# Train the model on the training data
model.fit(X_reg_train, y_reg_train, epochs=50, batch_size=32, verbose=2)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The provided solution in the course for the mentioned video section 2: Neural Network Calssiifcation in TensorFlow doesn't work for some reason. So I figured out this solution instead:
Beta Was this translation helpful? Give feedback.
All reactions