conv-neural-network

Illegal Instruction: 4 error when running any Tensorflow program

ⅰ亾dé卋堺 提交于 2021-02-05 07:35:23
问题 I am trying to train a Tensorflow Convolutional Neural Network, and I am always getting a cryptic error regardless of the environment in which i run the program. In Jupyter Notebook, the kernel simply dies. In Terminal, I get "Illegal Instruction: 4" with no Traceback. In Pycharm, I get: "Process finished with exit code 132 (interrupted by signal 4: SIGILL)". I have looked all over the Internet and I have not found any instance in which this particular error was thrown in this situation. I

load a pretrained model pytorch - dict object has no attribute eval

谁都会走 提交于 2021-02-04 19:13:09
问题 def save_checkpoint(state, is_best, filename='checkpoint.pth.tar'): torch.save(state, filename) if is_best: shutil.copyfile(filename, 'model_best.pth.tar') save_checkpoint({ 'epoch': epoch + 1, 'arch': args.arch, 'state_dict': model.state_dict(), 'best_prec1': best_prec1, 'optimizer': optimizer.state_dict() }, is_best) I am saving my model like this. How can I load back the model so that I can use it in other places, like cnn visualization? This is how I am loading the model now: torch.load(

Use pretrained model with different input shape and class model

北城余情 提交于 2021-02-04 17:37:30
问题 I am working on a classification problem using CNN where my input image size is 64X64 and I want to use pretrained model such as VGG16 , COCO or any other. But the problem is input image size of pretrained model is 224X224 . How do I sort this issue. Is there any data augmentation way for input image size. If I resize my input image to 224X224 then there is very high chance of image will get blurred and that may impact the training. Please correct me if I am wrong. Another question is related

Set half of the filters of a layer as not trainable keras/tensorflow

放肆的年华 提交于 2021-02-04 14:56:22
问题 I'm trying to train a model suggested by this research paper where I set half of the filters of a convolution layer to Gabor filters and the rest are random weights which are initialized by default. Normally, if I have to set a layer as not trainable, I set the trainable attribute as False . But here I have to freeze only half of the filters of a layer and I have no idea how to do so. Any help would be really appreciated. I'm using Keras with Tensorflow backend. 回答1: How about making two

Set half of the filters of a layer as not trainable keras/tensorflow

坚强是说给别人听的谎言 提交于 2021-02-04 14:55:08
问题 I'm trying to train a model suggested by this research paper where I set half of the filters of a convolution layer to Gabor filters and the rest are random weights which are initialized by default. Normally, if I have to set a layer as not trainable, I set the trainable attribute as False . But here I have to freeze only half of the filters of a layer and I have no idea how to do so. Any help would be really appreciated. I'm using Keras with Tensorflow backend. 回答1: How about making two

How do I use Tensorflow tf.nn.conv2 to make a convolutional layer?

别来无恙 提交于 2021-02-04 08:35:07
问题 With tf.nn.conv2d , you can perform a convolutional operation on a tensor. E.g. import tensorflow as tf x = tf.random.uniform(shape=(1, 224, 224, 3), dtype=tf.float32) filters = tf.random.uniform(shape=(1, 3, 3, 10)) tf.nn.conv2d(input=x, filters=filters, strides=1, padding='VALID') <tf.Tensor: shape=(1, 224, 222, 10), dtype=float32, numpy= array([[[[2.1705112, 1.2065555, 1.7674012, ..., 1.705754 , 1.3659815, 1.7028458], [2.0048866, 1.4835871, 1.2038497, ..., 1.8981357, 1.4605963, 2.148876 ],

Keras predict_classes method returns “list index out of range” error

∥☆過路亽.° 提交于 2021-01-29 17:11:06
问题 I am new to CNN and machine learning in general and have been trying to follow Image Classification tutorial of TensorFlow. Now, the Google Colab can be found here. I've followed the this official tutorial of TensorFlow. And I've changed it slightly so it saves the model as h5 instead of tf format so I can use the Keras' model.predict_classes . Now, I have the model trained and the model reloaded from the saved model alright. But I'm repeatedly getting list index out of range error whenever I

how to solve dimension mismatch error for CNN on images in pyTorch?

本小妞迷上赌 提交于 2021-01-29 12:06:30
问题 I have input data (colored images) in the shape of (100, 64, 64, 3) and tried to train a CNN with 2 conv/pooling layers on it for binary classification. I keep encountering size mismatch error. Also attempted reshape the images into (-1, 3, 64, 64) size class SimpleCNN(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim, kernel_size): super(SimpleCNN, self).__init__() self.conv1 = nn.Conv2d(3, 10, kernel_size, padding=0) self.conv2 = nn.Conv2d(10, 20, kernel_size, padding=0) self

Getting true labels for keras predictions

时光怂恿深爱的人放手 提交于 2021-01-29 10:15:17
问题 I have a standard CNN for image classification, using the following generator to get the dataset: generator = validation_image_generator.flow_from_directory(batch_size=BATCH_SIZE, directory=val_dir, shuffle=False, target_size=(100,100), class_mode='categorical') I can easily get the predicted labels with: predictions = model.predict(dataset) Now I want to get the (original) true labels and images for all the predictions, in the same order as the predictions in order to compare them. I am sure

TypeError: 'Tensor' object is not callable | Keras-Bert

守給你的承諾、 提交于 2021-01-29 09:31:13
问题 I'm building this model: inputs = model.inputs[:2] layer_output = model.get_layer('Encoder-12-FeedForward-Norm').output input_layer= keras.layers.Input(shape=(SEQ_LEN,768))(layer_output) conv_layer= keras.layers.Conv1D(100, kernel_size=3, activation='relu', data_format='channels_first')(input_layer) maxpool_layer = keras.layers.MaxPooling1D(pool_size=4)(conv_layer) flat_layer= keras.layers.Flatten()(maxpool_layer) outputs = keras.layers.Dense(units=3, activation='softmax')(flat_layer) model =