0

I am running below code and getting error as "AttributeError: module 'tensorflow_core.keras.layers' has no attribute 'Conv1d'". Any help will be grateful

import tensorflow as tf
print(tf.__version__)

(mnist_train, minst_train_label), (mnist_test, mnist_test_label) = tf.keras.datasets.mnist.load_data()

train_label_batch_int = tf.cast(minst_train_label, tf.int32) ## This is important because one tf.one_hot does not accept float
train_label_batch_onehot = tf.one_hot(train_label_batch_int, depth = 10)
test_label_batch_int = tf.cast(mnist_test_label, tf.int32) ## This is important because one tf.one_hot does not accept float
test_label_batch_onehot = tf.one_hot(test_label_batch_int, depth = 10) 
## converting to ndarray
if type(train_label_batch_onehot).__name__ != 'ndarray' :
 train_label_batch_onehot = train_label_batch_onehot.numpy()
 test_label_batch_onehot = test_label_batch_onehot.numpy()

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.layers import Conv1D

model = tf.keras.Sequential([
tf.keras.layers.Conv1D(32,5,activation=tf.nn.relu),
tf.keras.layers.Conv1D(32,5,activation=tf.nn.relu),
tf.keras.layers.MaxPooling1D(2,2),

tf.keras.layers.Conv1d(64,3,activation=tf.nn.relu),
tf.keras.layers.MaxPooling1D(2,2),

tf.keras.layers.Conv1d(128,3,activation=tf.nn.relu),
tf.keras.layers.flatten(),
tf.keras.layers.Dense(1024,activation=tf.nn.relu),
tf.keras.layers.Dense(256,activation=tf.nn.relu),
tf.keras.layers.Dense(10,activation=None)])

1 Answer 1

1

Spelling mistake . thank you its resolved. It should be Conv1D and not Conv1d

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.