neural-network

Keras Custom Layer 2D input -> 2D output

不想你离开。 提交于 2020-01-02 05:21:09
问题 I have an 2D input (or 3D if one consider the number of samples) and I want to apply a keras layer that would take this input and outputs another 2D matrix. So, for example, if I have an input with size (ExV), the learning weight matrix would be (SxE) and the output (SxV). Can I do this with Dense layer? EDIT (Nassim request): The first layer is doing nothing. It's just to give an input to Lambda layer: from keras.models import Sequential from keras.layers.core import Reshape,Lambda from

ValueError: Tensor Tensor(…) is not an element of this graph. When using global variable keras model

半城伤御伤魂 提交于 2020-01-02 05:21:09
问题 I'm running a web server using flask and the error comes up when I try to use vgg16, which is the global variable for keras' pre-trained VGG16 model. I have no idea why this error rises or whether it has anything to do with the Tensorflow backend. Here is my code: vgg16 = VGG16(weights='imagenet', include_top=True) def getVGG16Prediction(img_path): global vgg16 img = image.load_img(img_path, target_size=(224, 224)) x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input

Classification: skewed data within a class

大憨熊 提交于 2020-01-02 02:26:09
问题 I'm trying to build a multilabel-classifier to predict the probabilities of some input data being either 0 or 1. I'm using a neural network and Tensorflow + Keras (maybe a CNN later). The problem is the following: The data is highly skewed. There are a lot more negative examples than positive maybe 90:10. So my neural network nearly always outputs very low probabilities for positive examples. Using binary numbers it would predict 0 in most of the cases. The performance is > 95% for nearly all

NARX Neural network prediction?

試著忘記壹切 提交于 2020-01-01 19:42:49
问题 I am trying to solve a time series problem using the NARX Neural Network solution that Matlab provides. I am trying to understand how to predict actual values, but the results I get are almost perfect! The errors are so small that I am not sure if I am actually predicting. I just want to make sure I am doing everything right! Basically I train the network with some samples using the GUI solution. Then I use the following script to test the neural network with new samples: X = num2cell(open2(1

Tensorflow Grid LSTM RNN TypeError

倾然丶 夕夏残阳落幕 提交于 2020-01-01 18:16:31
问题 I'm trying to build a LSTM RNN that handles 3D data in Tensorflow. From this paper, Grid LSTM RNN's can be n-dimensional. The idea for my network is a have a 3D volume [depth, x, y] and the network should be [depth, x, y, n_hidden] where n_hidden is the number of LSTM cell recursive calls. The idea is that each pixel gets its own "string" of LSTM recursive calls. The output should be [depth, x, y, n_classes] . I'm doing a binary segmentation -- think foreground and background, so the number

Using all Input Variables in neuralnet in R

♀尐吖头ヾ 提交于 2020-01-01 16:58:14
问题 I'm trying to create a simple Neural Network in R using the nerualnet package. Instead of typing out all 784 input variables I am just using a . like is suggested in this thread: neural network using all input variables? But I am getting this error > digitnet <- neuralnet(label ~ ., trainingset, hidden = 4) Error in terms.formula(formula) : '.' in formula and no 'data' argument 回答1: I don't know why that doesn't work but you can always use the following: myform <- as.formula(paste0('label ~ '

Help me with my backprop implementation in Python

旧巷老猫 提交于 2020-01-01 09:40:05
问题 EDIT2: New training set... Inputs: [ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0], [0.0, 4.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [2.0, 0.0], [2.0, 1.0], [2.0, 2.0], [2.0, 3.0], [2.0, 4.0], [3.0, 0.0], [3.0, 1.0], [3.0, 2.0], [3.0, 3.0], [3.0, 4.0], [4.0, 0.0], [4.0, 1.0], [4.0, 2.0], [4.0, 3.0], [4.0, 4.0] ] Outputs: [ [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [1.0], [1.0], [0.0],

How do I create a function at runtime in Objective-C

末鹿安然 提交于 2020-01-01 07:08:11
问题 So it's late here, and my google skills seem to be failing me. I've found some great responses on SO before (time and time again), I thought you guys could help. I have a neural network I'm trying to run in native objective-c. It works, but it's too slow. These networks are not recurrent. Each network I run about 20,000 times ( 128x80 times, or around that). The problem is these networks really just boil down to math functions (each network is a 4 dimensional function, taking x,y,dist(x,y)

Gradient Descent vs Stochastic Gradient Descent algorithms

允我心安 提交于 2020-01-01 05:49:05
问题 I tried to train a FeedForward Neural Network on the MNIST Handwritten Digits dataset (includes 60K training samples). I each time iterated over all the training samples , performing Backpropagation for each such sample on every epoch. The runtime is of course too long. Is the algorithm I ran named Gradient Descent ? I read that for large datasets, using Stochastic Gradient Descent can improve the runtime dramatically. What should I do in order to use Stochastic Gradient Descent ? Should I

Get weights from tensorflow model

岁酱吖の 提交于 2020-01-01 05:39:16
问题 Hello I would like to finetune VGG model from tensorflow. I have two questions. How to get the weights from network? The trainable_variables returns empty list for me. I used existing model from here: https://github.com/ry/tensorflow-vgg16 . I find the post about getting weights however this doesn't work for me because of import_graph_def. Get the value of some weights in a model trained by TensorFlow import tensorflow as tf import PIL.Image import numpy as np with open("../vgg16.tfmodel",