conv-neural-network

dump weights of cnn in json using keras

て烟熏妆下的殇ゞ 提交于 2019-12-09 13:15:11
问题 I want to use the dumped weights and model architecture in other framework for testing. I know that: model.get_config() can give the configuration of the model model.to_json returns a representation of the model as a JSON string, but that the representation does not include the weights, only the architecture model.save_weights(filepath) saves the weights of the model as a HDF5 file I want to save the architecture as well as weights in a json file. 回答1: Keras does not have any built-in way to

Layer names for pretrained inception v3 model (tensorflow) [duplicate]

半城伤御伤魂 提交于 2019-12-09 12:16:56
问题 This question already has answers here : List of tensor names in graph in Tensorflow (6 answers) Closed 3 years ago . The task is to get per-layer output of a pretrained cnn inceptionv3 model. For example I feed an image to this network, and I want to get not only its output, but output of each layer(layer-wise). In order to do that, I have to know names of each layer output. It's quite easy to do for last and pre-last layer: sess.graph.get_tensor_by_name('pool_3:0') sess.graph.get_tensor_by

Keras cifar10 example validation and test loss lower than training loss

↘锁芯ラ 提交于 2019-12-09 10:58:42
问题 I'm playing around with the cifar10 example from Keras which you can find here. I've recreated the model (i.e., not same file but everything else pretty much the same) and you can find it here. The model is identical and I train the model for 30 epochs with 0.2 validation split on the 50,000 image training set. I'm not able to understand the result I get. My validation and testing loss is lesser than the training less (inversely, training accuracy is the lower compared to the validation and

How to use caffe convnet library to detect facial expressions?

杀马特。学长 韩版系。学妹 提交于 2019-12-09 07:18:14
问题 How can I use caffe convnet to detect facial expressions? I have a image dataset, Cohn Kanade, and I want to train caffe convnet with this dataset. Caffe has a documentation site, but its not explain how to train my own data. Just with pre trained data. Can someone teach me how to do it? 回答1: Caffe supports multiple formats for the input data (HDF5/lmdb/leveldb). It's just a matter of picking the one you feel most comfortable with. Here are a couple of options: caffe/build/tools/convert

float16 vs float32 for convolutional neural networks

若如初见. 提交于 2019-12-09 05:21:06
问题 The standard is float32 but I'm wondering under what conditions it's ok to use float16? I've compared running the same covnet with both datatypes and haven't noticed any issues. With large dataset I prefer float16 because I can worry less about memory issues.. 回答1: Surprisingly, it's totally OK to use 16 bits, even not just for fun, but in production as well. For example, in this video Jeff Dean talks about 16-bit calculations at Google, around 52:00. A quote from the slides: Neural net

ValueError: `decode_predictions` expects a batch of predictions (i.e. a 2D array of shape (samples, 1000)). Found array with shape: (1, 7)

心已入冬 提交于 2019-12-09 01:08:48
问题 I am using VGG16 with keras for transfer learning (I have 7 classes in my new model) and as such I want to use the build-in decode_predictions method to output the predictions of my model. However, using the following code: preds = model.predict(img) decode_predictions(preds, top=3)[0] I receive the following error message: ValueError: decode_predictions expects a batch of predictions (i.e. a 2D array of shape (samples, 1000)). Found array with shape: (1, 7) Now I wonder why it expects 1000

How to load only specific weights on Keras

南楼画角 提交于 2019-12-08 22:55:45
问题 I have a trained model that I've exported the weights and want to partially load into another model. My model is built in Keras using TensorFlow as backend. Right now I'm doing as follows: model = Sequential() model.add(Conv2D(32, (3, 3), input_shape=input_shape, trainable=False)) model.add(Activation('relu', trainable=False)) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(32, (3, 3), trainable=False)) model.add(Activation('relu', trainable=False)) model.add(MaxPooling2D(pool_size

How does one debug NaN values in TensorFlow?

自闭症网瘾萝莉.ら 提交于 2019-12-08 22:43:31
问题 I was running TensorFlow and I happen to have something yielding a NaN. I'd like to know what it is but I do not know how to do this. The main issue is that in a "normal" procedural program I would just write a print statement just before the operation is executed. The issue with TensorFlow is that I cannot do that because I first declare (or define) the graph, so adding print statements to the graph definition does not help. Are there any rules, advice, heuristics, anything to track down

Is it possible to have non-trainable layer in Keras?

我是研究僧i 提交于 2019-12-08 21:02:22
问题 I would like to calculate constant convolution like blurring or resampling and want it never change during training. Can I initialize convolution kernel to constant and exclude it from training in Keras? More specifically, I don't want to use this for purposes declared in the doc. I want to implement residual network this way: one branch does normal trainable convolution, while parallel branch does something constant, like averaging. 回答1: You should be able to pass a trainable = False

Can one only implement gradient descent like optimizers with the code example from processing gradients in TensorFlow?

只愿长相守 提交于 2019-12-08 17:43:37
问题 I was looking at the example code for processing gradients that TensorFlow has: # Create an optimizer. opt = GradientDescentOptimizer(learning_rate=0.1) # Compute the gradients for a list of variables. grads_and_vars = opt.compute_gradients(loss, <list of variables>) # grads_and_vars is a list of tuples (gradient, variable). Do whatever you # need to the 'gradient' part, for example cap them, etc. capped_grads_and_vars = [(MyCapper(gv[0]), gv[1]) for gv in grads_and_vars] # Ask the optimizer