deep-learning

How to create a layer to invert a softmax (TensforFlow,python)?

£可爱£侵袭症+ 提交于 2021-02-05 12:08:30
问题 I am building a deconvolution network. I would like to add a layer to it which is the reverse of a softmax. I tried to write a basic python function that returns the inverse of a softmax for a given matrix and put that in a tensorflow Lambda and add it to my model. I have no error but when I doing a predict I only have 0 at the exit. When I don't add this layer to my network I have output something other than zeros. This therefore justifies that they are due to my inv_softmax function which

How to create a layer to invert a softmax (TensforFlow,python)?

谁都会走 提交于 2021-02-05 12:08:26
问题 I am building a deconvolution network. I would like to add a layer to it which is the reverse of a softmax. I tried to write a basic python function that returns the inverse of a softmax for a given matrix and put that in a tensorflow Lambda and add it to my model. I have no error but when I doing a predict I only have 0 at the exit. When I don't add this layer to my network I have output something other than zeros. This therefore justifies that they are due to my inv_softmax function which

Number Recognition on 7 segment using python

情到浓时终转凉″ 提交于 2021-02-05 11:29:07
问题 I am writing a code on Jupyter notebook using python to recognize the number on the device with 7segment(FND). I used opencv and got the edge of the image. import cv2 import matplotlib.pyplot as plt def detect_edge(image): ''' function Detecting Edges ''' image_with_edges = cv2.Canny(image , 100, 200) images = [image , image_with_edges] location = [121, 122] for loc, img in zip(location, images): plt.subplot(loc) plt.imshow(img, cmap='gray') plt.savefig('edge.png') plt.show() image = cv2

How can I explore and modify the created dataset from tf.keras.preprocessing.image_dataset_from_directory()?

穿精又带淫゛_ 提交于 2021-02-05 08:51:43
问题 Here's how I used the function: dataset = tf.keras.preprocessing.image_dataset_from_directory( main_directory, labels='inferred', image_size=(299, 299), validation_split=0.1, subset='training', seed=123 ) I'd like to explore the created dataset much like in this example, particularly the part where it was converted to a pandas dataframe. But my minimum goal is to check the labels and the number of files attached to it, just to check if, indeed, it created the dataset as expected (sub

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(

In PyTorch how are layer weights and biases initialized by default?

橙三吉。 提交于 2021-02-04 17:38:05
问题 I was wondering how are layer weights and biases initialized by default? E.g. if I create the linear layer torch.nn.Linear(5,100) How are weights and biases for this layer initialized by default? 回答1: PyTorch 1.0 Most layers are initialized using Kaiming Uniform method. Example layers include Linear, Conv2d, RNN etc. If you are using other layers, you should look up that layer on this doc. If it says weights are initialized using U(...) then its Kaiming Uniform method. Bias is initialized

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

Python Anaconda reinstall

醉酒当歌 提交于 2021-02-04 15:57:27
问题 I had a working deep learning library on CPU Linux Mint ubuntu verion 18.3 with Anaconda 3.6 but something got hosed when I was tinkering around in Theano. https://machinelearningmastery.com/setup-python-environment-machine-learning-deep-learning-anaconda/ Everything was working just fine until I wanted to tinker around with a few .py files with KERAS_BACKEND=theano python program.py and in an attempt to fix something not working in Theano, I did this command from the theano website http:/

Python Anaconda reinstall

那年仲夏 提交于 2021-02-04 15:57:06
问题 I had a working deep learning library on CPU Linux Mint ubuntu verion 18.3 with Anaconda 3.6 but something got hosed when I was tinkering around in Theano. https://machinelearningmastery.com/setup-python-environment-machine-learning-deep-learning-anaconda/ Everything was working just fine until I wanted to tinker around with a few .py files with KERAS_BACKEND=theano python program.py and in an attempt to fix something not working in Theano, I did this command from the theano website http:/

TypeError: The added layer must be an instance of class Layer. Found: <keras.engine.training.Model object at 0x7fa5bee17ac8>

家住魔仙堡 提交于 2021-02-02 09:56:45
问题 I am try to train a model using Xception /Inception Model of keras library but I face value error Dataset which I use it from kaggle commuinity and Notebook which I refer Notebook But I am try to use different Model like Xception /Inception but silmilar idea not work for me with strategy.scope(): enet = keras.applications.inception_v3.InceptionV3( input_shape=(512, 512, 3), weights='imagenet', include_top=False ) model = tf.keras.Sequential([ enet, tf.keras.layers.GlobalAveragePooling2D(), tf