tensorflow

tf.keras.utils.get_file error: TypeError: '<' not supported between instances of 'int' and 'NoneType'

tf.keras.utils.get_file error: TypeError: '<' not supported between instances of 'int' and 'NoneType' Question: everyone, Recently I start to program with tensorflow 2.10.0, have the following codes in my ipynb file (Jupyter Notebook file): if not data_dir.exists(): tf.keras.utils.get_file(‘free-spoken-digit-dataset-master.zip’,origin="https://codeload.github.com/Jakobovski/free-spoken-digit-dataset/zip/refs/heads/master",extract=True,cache_dir=’.’,cache_subdir=’data’) I want to download the file free-spoken-digit-dataset-master.zip from the URL https://codeload.github.com/Jakobovski/free-spoken-digit-dataset/zip/refs/heads/master, after running the codes the following error …

Total answers: 2

Loss is Nan for SegFormer vision transformer trained on BDD10k

Loss is Nan for SegFormer vision transformer trained on BDD10k Question: I’m trying to implement a SegFormer pretrained with a mit-b0 model to perform semantic segmentation on images obtained from the bdd100k dataset. Specifically, semantic segmentation has masks for only a subset of the 100k images, being 10k with appropriate masks for segmentation where the …

Total answers: 4

Can i initialize optimizer before changing the last layer of my model

Can i initialize optimizer before changing the last layer of my model Question: Say I want to change the last layer of my code but my optimizer is defined on the top of my scripts, what is a better practise? batch_size = 8 learning_rate = 2e-4 num_epochs = 100 cnn = models.resnet18(weights=’DEFAULT’) loss_func = nn.CrossEntropyLoss() …

Total answers: 1

Shapes for training data and labels

Shapes for training data and labels Question: I am trying to train a convolutional neural network using Conv1D and sparse_categorical_crossentropy as a loss function but I keep having problems related to the shapes of the data. Here is the network: model=models.Sequential() model=tf.keras.models.Sequential([ tf.keras.layers.Conv1D(16, 24, input_shape=(1000, 4), activation="relu"), tf.keras.layers.MaxPooling1D(pool_size=24, strides=24), tf.keras.layers.Conv1D(8, 8, activation="relu"), tf.keras.layers.MaxPooling1D(pool_size=8, strides=8), tf.keras.layers.Flatten(), …

Total answers: 1

WARNING:tensorflow:Early stopping conditioned on metric `val_loss` which is not available. Available metrics are: loss,recall

WARNING:tensorflow:Early stopping conditioned on metric `val_loss` which is not available. Available metrics are: loss,recall Question: I have the error in the title when running the code below: def create_model(learning_rate, dropout, l2_lambda): model = Sequential() model.add(Dense(128,input_dim=X_train.shape[1], activation=’relu’, kernel_regularizer=regularizers.l2(l2_lambda))) model.add(BatchNormalization()) model.add(Dropout(dropout)) model.add(Dense(64, activation=’relu’, kernel_regularizer=regularizers.l2(l2_lambda))) model.add(Dropout(dropout)) model.add(Dense(1, activation=’sigmoid’)) optimizer = Adam(learning_rate=learning_rate) model.compile(loss=’binary_crossentropy’, optimizer=optimizer, metrics=[‘Recall’]) return model early_stopping = …

Total answers: 1

why my tf.tensor_scatter_nd_add can't do the same as torch scatter_add_

why my tf.tensor_scatter_nd_add can't do the same as torch scatter_add_ Question: new_means = tf.tensor_scatter_nd_add(new_means, indices=repeat(buckets, "n -> n d", d=dim), updates=samples) assumpt new_means.shape=[3, 4], indices.shape=[4, 4] and updates.sahpe=[4, 4]. the above code return err : Inner dimensions of output shape must match inner dimensions of updates shape. Output: [3,4] updates: [4,4]. even when I set …

Total answers: 1

How does TensorFlow perform algorithms so fast?

How does TensorFlow perform algorithms so fast? Question: I wanted to solve a linear regression problem by creating by myself the Adam optimization algorithm and performing it on my dataset. However, the problem is solved with an acceptable loss in around 100 epochs, while a tenth than my loss is computed by TensorFlow in just …

Total answers: 1

x and y must have same first dimension, but have shapes (9,) and (4,)

x and y must have same first dimension, but have shapes (9,) and (4,) Question: y_pred = fig.predict(x.reshape(1, -1)).reshape(-1) colors_dark = ["#1F1FIF", "#313131", "#636363", "#AEAEAE", "#DADADA"] colors_red = ["#331313", "#582626", "#9E1717", "#D35151", "#E9B4B4"] colors_green=[ "# 01411C", "#4B6F44", "#4F7942", "#74C365", "#D0F0C0"] filterwarnings("ignore") epochs =[ i for i in range(9)] fig, ax = plt.subplots(1, 2,figsize=(14,7)) train_acc1 = …

Total answers: 1

tf keras autokeras with early stopping returns empty history

tf keras autokeras with early stopping returns empty history Question: I am trying different models for the same dataset, being autokeras.ImageClassifier one of them. First I go for img_size = (100,120,3) train_dataset = get_dataset(x_train, y_train, img_size[:-1], 128) valid_dataset = get_dataset(x_valid, y_valid, img_size[:-1], 128) test_dataset = get_dataset(x_test, y_test, img_size[:-1], 128) For getting the dataset with a …

Total answers: 1

On windows11, nvcc cannot show the correct version of CUDA

On windows11, nvcc cannot show the correct version of CUDA Question: The version I originally installed is 11.6. To match the tensorflow2.11.0, I had to install the v11.2 of CUDA, during which I first uinstall the newer version of CUDA(every thing about it) and then install the earlier version that is 11.2. However, after the …

Total answers: 1