neural-network

What is the difference between Keras model.evaluate() and model.predict()?

时间秒杀一切 提交于 2019-12-21 09:20:20
问题 I used Keras biomedical image segmentation to segment brain neurons. I used model.evaluate() it gave me Dice coefficient: 0.916. However, when I used model.predict() , then loop through the predicted images by calculating the Dice coefficient, the Dice coefficient is 0.82. Why are these two values different? 回答1: The problem lies in the fact that every metric in Keras is evaluated in a following manner: For each batch a metric value is evaluated. A current value of loss (after k batches is

How do you use Keras LeakyReLU in Python?

南楼画角 提交于 2019-12-21 06:53:42
问题 I am trying to produce a CNN using Keras, and wrote the following code: batch_size = 64 epochs = 20 num_classes = 5 cnn_model = Sequential() cnn_model.add(Conv2D(32, kernel_size=(3, 3), activation='linear', input_shape=(380, 380, 1), padding='same')) cnn_model.add(Activation('relu')) cnn_model.add(MaxPooling2D((2, 2), padding='same')) cnn_model.add(Conv2D(64, (3, 3), activation='linear', padding='same')) cnn_model.add(Activation('relu')) cnn_model.add(MaxPooling2D(pool_size=(2, 2), padding=

How to implement mini-batch gradient descent in python?

自古美人都是妖i 提交于 2019-12-21 06:18:33
问题 I have just started to learn deep learning. I found myself stuck when it came to gradient descent. I know how to implement batch gradient descent. I know how it works as well how mini-batch and stochastic gradient descent works in theory. But really can't understand how to implement in code. import numpy as np X = np.array([ [0,0,1],[0,1,1],[1,0,1],[1,1,1] ]) y = np.array([[0,1,1,0]]).T alpha,hidden_dim = (0.5,4) synapse_0 = 2*np.random.random((3,hidden_dim)) - 1 synapse_1 = 2*np.random

Extracting weights from .caffemodel without caffe installed in Python

£可爱£侵袭症+ 提交于 2019-12-21 05:46:07
问题 Is there a relatively simple way to extract weights in Python from one of the many pretrained models in Caffe Zoo WITHOUT CAFFE (nor pyCaffe)? i.e. parsing .caffemodel to hdf5/numpy or whatever format that can be read by Python? All the answers I found use C++ code with caffe classes or Pycaffe. I have looked at pycaffe's code it looks like you really need caffe to make sense of the binary is that the only solution? 回答1: I had to resolve that exact issue just now. Assuming you have a

How reconstruct the caffe net by using pycaffe

可紊 提交于 2019-12-21 05:05:00
问题 What I want is, After loading a net, I will decompose some certain layers and save the new net. For example Orignial net: data -> conv1 -> conv2 -> fc1 -> fc2 -> softmax; New net: data -> conv1_1 -> conv1_2 -> conv2_1 -> conv2_2 -> fc1 -> fc2 -> softmax Therefore, during this process, I stuck in the following situation: 1. How to new a certain layer with specified layer parameters in pycaffe ? 2. How to copy the layer parameters from existing layers(such as fc1 and fc2 above)? I know by using

Training darknet finishes immediately

不羁的心 提交于 2019-12-21 04:51:19
问题 I would like to use the yolo architecture for object detection. Before training the network with my custom data, I followed these steps to train it on the Pascal VOC data: https://pjreddie.com/darknet/yolo/ The instructions are very clear. But after the final step ./darknet detector train cfg/voc.data cfg/yolo-voc.cfg darknet19_448.conv.23 darknet immediately stops training and announces that weights have been written to the backups/ directory. At first I thought that the pretraining was

How to use keras ImageDataGenerator with a Siamese or Tripple networks

丶灬走出姿态 提交于 2019-12-21 04:32:03
问题 I'm trying to build up both a Siamese neural network and triple neural network on a custom large dataset Keras has ImageDataGenerator which makes the generation of input data to a regular neural network very easy. I'm interesting to use ImageDataGenerator or similar ways in order to train a networks with 2( siamese ) and 3( triple ) inputs. In mniset keras siamese example, The input generated by a pre-process stage which is done by create_pairs method. I don't think this kind of way fit for a

Can someone explain Artificial Neural Networks? [closed]

血红的双手。 提交于 2019-12-21 04:21:44
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . According to Wikipedia (which is a bad source, I know) A neural network is comprised of An input layer of A neurons Multiple (B) Hidden layers each comprised of C neurons. An output layer of "D" neurons. I

Keras IndexError: indices are out-of-bounds

流过昼夜 提交于 2019-12-21 03:51:18
问题 I'm new to Keras and im trying to do Binary MLP on a dataset, and keep getting indices out of bounds with no idea why. from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation from keras.optimizers import SGD model = Sequential() model.add(Dense(64, input_dim=20, init='uniform', activation='relu')) model.add(Dropout(0.5)) model.add(Dense(64, activation='relu')) model.add(Dropout(0.5)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary

Loss suddenly increases with Adam Optimizer in Tensorflow

旧巷老猫 提交于 2019-12-21 03:44:50
问题 I am using a CNN for a regression task. I use Tensorflow and the optimizer is Adam. The network seems to converge perfectly fine till one point where the loss suddenly increases along with the validation error. Here are the loss plots of the labels and the weights separated (Optimizer is run on the sum of them) I use l2 loss for weight regularization and also for the labels. I apply some randomness on the training data. I am currently trying RSMProp to see if the behavior changes but it takes