运行Keras例子程序:imdb_cnn.py
来源:互联网 发布:org.apache.cxf maven 编辑:程序博客网 时间:2024/06/06 09:11
下载例子程序:https://github.com/fchollet/keras
函数解析
1)keras.layers.embeddings.Embedding(input_dim, output_dim, init='uniform', input_length=None, W_regularizer=None, activity_regularizer=None, W_constraint=None, mask_zero=False, weights=None, dropout=0.0)
Example
# -*- coding: utf-8 -*-"""Created on Mon Jun 06 15:30:07 2016@author: Michelle"""from __future__ import print_functionimport numpy as npfrom keras.models import Sequentialfrom keras.layers import Embeddingmodel = Sequential()#该模型的输入为一个整数矩阵(batch, input_length),#输出为三维矩阵(batch, input_length, 64),即每行的输入生成一个矩阵(input_length, 64)model.add(Embedding(1000, 64, input_length=10)) # the model will take as input an integer matrix of size (batch, input_length). # the largest integer (i.e. word index) in the input should be no larger than 999 (vocabulary size). # now model.output_shape == (None, 10, 64), where None is the batch dimension.#输入:1000以内,32*10的随机二维整数矩阵input_array = np.random.randint(1000, size=(32, 10))model.compile('rmsprop', 'mse')#输出:三维矩阵output_array = model.predict(input_array)assert output_array.shape == (32, 10, 64)
运行程序时出现的错误:
1)EOFError
原因:重复下载文件没有中断
解决:到 C:\Users\Michelle\.keras\datasets下删除*.pkl文件
0 0
- 运行Keras例子程序:imdb_cnn.py
- 运行keras mnist_mlp.py错误解决
- Keras入门mnist_mlp.py
- Windows7中双击py文件运行程序
- python运行第一个.py程序
- 运行tensorflow基本程序mnist.py
- keras 2.0.1+theano 0.8.2 运行 mnist_cnn.py 报错
- keras imdb.py源码错误
- Keras 例程lmdb_lstm.py理解
- ubuntu16.04 keras程序运行报错和解决
- 【例子】堆栈中运行程序
- keras例子-matchnet
- 如何在python下直接运行py程序
- 如何在python shell下直接运行py程序
- py学习之路2-通过文件运行程序
- 在servlet中运行调用py程序不成功问题
- 在Windows的命令窗口运行.py程序
- keras第一个例程mnist_mlp.py解读
- display:inline、block、inline-block的区别,与下文float相关。
- Apache shiro集群实现 (一) shiro入门介绍
- (转载)使用Xcode7的Instruments检测解决iOS内存泄露
- 关于数据库主键和外键(终于弄懂啦)
- iOS音频处理技术-TAAE
- 运行Keras例子程序:imdb_cnn.py
- 常用资料备忘
- Git学习笔记
- Merge Sorted Array(easy)
- C#中的ASCII转换
- 盲打
- ★【16.6.2】Codeforces Round #355 (Div. 2) A. Vanya and Fence
- iOS 屏幕方向
- Python装饰器与面向切面编程