neural-network

Using categorical_crossentropy for only two classes

纵饮孤独 提交于 2020-01-25 07:03:22
问题 Computer vision and deep learning literature usually say one should use binary_crossentropy for a binary (two-class) problem and categorical_crossentropy for more than two classes. Now I am wondering: is there any reason to not use the latter for a two-class problem as well? 回答1: categorical_crossentropy : accepts only one correct class per sample will take "only" the true neuron and make the crossentropy calculation with that neuron binary_crossentropy : accepts many correct classes per

Transformer model not able to be saved

故事扮演 提交于 2020-01-25 06:41:09
问题 I'm trying to follow this tutrial https://colab.research.google.com/github/tensorflow/examples/blob/master/community/en/transformer_chatbot.ipynb, However, when I tried to save the model in order to load it again without training I got an error mentioned here NotImplementedError: Layers with arguments in `__init__` must override `get_config` I understood from the answer that I need to make the encoder and decoder as classes and customise it(instead of leaving it as functions like the colab

Tensorflow crash with CUDNN_STATUS_ALLOC_FAILED

坚强是说给别人听的谎言 提交于 2020-01-25 01:04:20
问题 Been searching the web for hours with no results, so figured I'd ask here. I'm trying to make a self driving car following Sentdex's tutorial, but when running the model, I get a bunch of fatal errors. I've searched all over the internet for the solution, and many seem to have the same problem. However, none of the solutions I've found (Including this Stack-post), work for me. Here is my software: Tensorflow: 1.5, GPU version CUDA: 9.0, with the patch CUDnn: 7 Windows 10 Pro Python 3.6

Error when checking model target: expected dense_39 to have 3 dimensions, but got array with shape (940, 1)

China☆狼群 提交于 2020-01-24 23:59:12
问题 I'm trying to train this Convolutional Neural Network but can't figure out what the issue is with my last layer. model = Sequential() model.add(Conv1D(50, kernel_size=(1), activation='relu', input_dim=50)) model.add(Dense(32)) model.add(Dense(1)) model.summary() model.compile(loss=keras.losses.mean_squared_error, optimizer=keras.optimizers.adam()) model.fit(X_train, y_train, batch_size=940, epochs=10, verbose=1, validation_data=(X_test, y_test)) Model: ________________________________________

How do you unit test code that relies on randomly generated numbers?

£可爱£侵袭症+ 提交于 2020-01-24 22:11:06
问题 What is the best way to unit test code that relies on you randomly generating data? I found this question on stack overflow but it is a little different. I know that you can use fixtures to mock out something like a database but I think that what I'm trying to do is a little different. I'm trying to write an adaline neural network. This requires me to randomly generate weights and then the values for the weights are adjusted as more data is presented to the network. How do I unit test

Calculate the accuracy every epoch in PyTorch

心已入冬 提交于 2020-01-24 19:52:05
问题 I am working on a Neural Network problem, to classify data as 1 or 0. I am using Binary cross entropy loss to do this. The loss is fine, however, the accuracy is very low and isn't improving. I am assuming I did a mistake in the accuracy calculation. After every epoch, I am calculating the correct predictions after thresholding the output, and dividing that number by the total number of the dataset. Is there any thing wrong I did in the accuracy calculation? And why isn't it improving, but

Calculate dimension of feature maps in convolutional neural network

橙三吉。 提交于 2020-01-24 06:13:27
问题 I have convolutional neural network in Keras. I need to know the dimensions of the feature maps in each layer. My input is 28 by 28 pixel image. I know theres a way to calculate this I not sure how. Below is my code snippet using Keras. img_rows, img_cols = 28, 28 nb_filters = 32 nb_pool = 2 nb_conv = 3 model = Sequential() model.add(Convolution2D(nb_filters, nb_conv, nb_conv, border_mode='valid', input_shape=(1, img_rows, img_cols))) model.add(Activation('relu')) model.add(Convolution2D(nb

Calculate dimension of feature maps in convolutional neural network

感情迁移 提交于 2020-01-24 06:10:30
问题 I have convolutional neural network in Keras. I need to know the dimensions of the feature maps in each layer. My input is 28 by 28 pixel image. I know theres a way to calculate this I not sure how. Below is my code snippet using Keras. img_rows, img_cols = 28, 28 nb_filters = 32 nb_pool = 2 nb_conv = 3 model = Sequential() model.add(Convolution2D(nb_filters, nb_conv, nb_conv, border_mode='valid', input_shape=(1, img_rows, img_cols))) model.add(Activation('relu')) model.add(Convolution2D(nb

Neural Network and Temporal Difference Learning

限于喜欢 提交于 2020-01-24 05:25:07
问题 I have a read few papers and lectures on temporal difference learning (some as they pertain to neural nets, such as the Sutton tutorial on TD-Gammon) but I am having a difficult time understanding the equations, which leads me to my questions. -Where does the prediction value V_t come from? And subsequently, how do we get V_(t+1)? -What exactly is getting back propagated when TD is used with a neural net? That is, where does the error that gets back propagated come from when using TD? 回答1:

How to fix module 'tensorflow' has no attribute 'get_default_session'

一笑奈何 提交于 2020-01-24 00:43:26
问题 Help solve that problem please I use ImageAI to detect cars , but it didn't works , i'm newbee in this , sorry from imageai.Detection import ObjectDetection import os execution_path = os.getcwd() detector = ObjectDetection() detector.setModelTypeAsRetinaNet() detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5")) detector.loadModel() detections, objects_path = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image3.jpg"), output_image