theano

how to get the outputs from the embedding layer

馋奶兔 提交于 2019-12-22 07:53:15
问题 from keras.models import Sequential from keras.layers.embeddings import Embedding from theano import function model = Sequential() model.add(Embedding(max_features, 128, input_length = maxlen)) I want to get the outputs from the embedding layers. I read through the source in keras but didnt find any suitable function or attribute. Anyone can help me with this? 回答1: You can get the output of any layer, not just an embedding layer, as described here: from keras import backend as K get_3rd_layer

how to get the outputs from the embedding layer

无人久伴 提交于 2019-12-22 07:52:32
问题 from keras.models import Sequential from keras.layers.embeddings import Embedding from theano import function model = Sequential() model.add(Embedding(max_features, 128, input_length = maxlen)) I want to get the outputs from the embedding layers. I read through the source in keras but didnt find any suitable function or attribute. Anyone can help me with this? 回答1: You can get the output of any layer, not just an embedding layer, as described here: from keras import backend as K get_3rd_layer

Keras GRU NN KeyError when fitting : “not in index”

不问归期 提交于 2019-12-22 05:43:08
问题 I'm currently facing an issue while trying to fit my GRU model with my training data. After a quick look on StackOverflow, I found this post to be quite similar to my issue : Simplest Lstm training with Keras io My own model is as follow : nn = Sequential() nn.add(Embedding(input_size, hidden_size)) nn.add(GRU(hidden_size_2, return_sequences=False)) nn.add(Dropout(0.2)) nn.add(Dense(output_size)) nn.add(Activation('linear')) nn.compile(loss='mse', optimizer="rmsprop") history = History() nn

Theano Import error

蓝咒 提交于 2019-12-22 04:25:09
问题 I am trying to install Theano on CPU machine (running intel HD graphics, without NVIDIA). I get the following import error while testing in python. WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to exe cute optimized C-implementations (for both CPU and GPU) and will default to Pyth on implementations. Performance will be severely degraded. To remove this warnin g, set Theano flags cxx to an empty string. Traceback (most recent call last): File "<stdin>", line 1, in

Python - Theano scan() function

。_饼干妹妹 提交于 2019-12-22 04:03:09
问题 I cannot fully understand the behaviour of theano.scan(). Here's an example: import numpy as np import theano import theano.tensor as T def addf(a1,a2): return a1+a2 i = T.iscalar('i') x0 = T.ivector('x0') step= T.iscalar('step') results, updates = theano.scan(fn=addf, outputs_info=[{'initial':x0, 'taps':[-2]}], non_sequences=step, n_steps=i) f=theano.function([x0,i,step],results) print f([1,1],10,2) The above snippet prints the following sequence, which is perfectly reasonable: [ 3 3 5 5 7 7

Using the TimeSeriesNnet() method from the nnet_ts module throws NameError

独自空忆成欢 提交于 2019-12-22 00:44:19
问题 I am trying to create a neural network using the python module nnet-ts. It has a built-in method named TimeSeriesNnet(), which takes two arguments; hidden_layers and activation_functions. See documentation for this module, as well as example in the README.md: https://github.com/hawk31/nnet-ts I am running python version 2.7.13 The nnet-ts module has dependencies to 5 particular packages, which I am listing below together with the current versions I am using: numpy-1.13.0, pandas-0.20.2, scipy

Convert numpy function to theano

让人想犯罪 __ 提交于 2019-12-21 23:36:17
问题 I am using PyMC3 to calculate something which I won't get into here but you can get the idea from this link if interested. The '2-lambdas' case is basically a switch function, which needs to be compiled to a Theano function to avoid dtype errors and looks like this: import theano from theano.tensor import lscalar, dscalar, lvector, dvector, argsort @theano.compile.ops.as_op(itypes=[lscalar, dscalar, dscalar], otypes=[dvector]) def lambda_2_distributions(tau, lambda_1, lambda_2): """ Return

How to implement Weighted Binary CrossEntropy on theano?

我与影子孤独终老i 提交于 2019-12-21 12:06:14
问题 How to implement Weighted Binary CrossEntropy on theano? My Convolutional neural network only predict 0 ~~ 1 (sigmoid). I want to penalize my predictions in this way : Basically, i want to penalize MORE when the model predicts 0 but the truth was 1. Question : How can I create this Weighted Binary CrossEntropy function using theano and lasagne ? I tried this below prediction = lasagne.layers.get_output(model) import theano.tensor as T def weighted_crossentropy(predictions, targets): # Copy

How to implement Weighted Binary CrossEntropy on theano?

萝らか妹 提交于 2019-12-21 12:06:07
问题 How to implement Weighted Binary CrossEntropy on theano? My Convolutional neural network only predict 0 ~~ 1 (sigmoid). I want to penalize my predictions in this way : Basically, i want to penalize MORE when the model predicts 0 but the truth was 1. Question : How can I create this Weighted Binary CrossEntropy function using theano and lasagne ? I tried this below prediction = lasagne.layers.get_output(model) import theano.tensor as T def weighted_crossentropy(predictions, targets): # Copy

anaconda python error importing theano

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 10:50:10
问题 I'm quite new in python and of course I'm also new with Theano. I'm trying to use it under windows along with anaconda python. I have installed all the compulsory requirements (except CUDA since on this laptop I don't have a NVIDIA GPU). I installed the same GCC and set the path as suggested in the walkthrough page. Still I get the following error: Problem occurred during compilation with the command line below: C:\TDM-GCC-64\bin\g++.exe -shared -g -march=broadwell -mmmx -mno-3dnow -msse