Python

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:LSTM网络层详解及其应用

fromkeras.layersimportLSTMmodel=Sequential()model.add(embedding_layer)model.add(LSTM(32))#当结果是输出多个分类的概率时,用softmax激活函数,它将为30个分类提供不同的可能性概率值model.add(layers.Dense(...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:RNN-具有记忆功能的神经网络

fromkeras.layersimportSimpleRNNmodel=Sequential()model.add(embedding_layer)model.add(SimpleRNN(32))#当结果是输出多个分类的概率时,用softmax激活函数,它将为30个分类提供不同的可能性概率值model.add(lay...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用训练好的单词向量实现新闻摘要分类

importpandasaspddf=pd.read_json('/Users/chenyi/Documents/News_Category_Dataset.json',lines=True)df.head()df.category=df.category.map(lambdax:"WORLDPOST"ifx=="TH...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:概率论的一些重要概念

importmatplotlib.pyplotaspltimportnumpyasnpimportmatplotlib.mlabasmlabimportmathmu=0variance=1sigma=math.sqrt(variance)x=np.linspace(mu-3*sigma,mu+3*sigma,100)p...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:自然语言处理Word Embedding 单词向量化

importnumpyasnpsamples=['Thecatjumpoverthedog','Thedogatemyhomework']#我们先将每个单词放置到一个哈希表中token_index={}forsampleinsamples:#将一个句子分解成多个单词forwordinsample.split():ifw...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:卷积神经网络的底层原理

defconv_(img,conv_filter):filter_size=conv_filter.shape[1]result=numpy.zeros((img.shape))print('loopr:',numpy.uint16(numpy.arange(filter_size/2.0,img.shape[0]-f...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:用预先训练好的卷积网络实现图像快速识别

fromkeras.preprocessingimportimagefromkeras.preprocessing.imageimportImageDataGeneratorimportosimportmatplotlib.pyplotaspltdatagen=ImageDataGenerator(rotation_r...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:构造一个识别猫、狗图片的卷积网络

importosbase_dir='/Users/apple/Documents/cat-and-dog'train_cats_dir=os.path.join(base_dir,'training_set/cats')train_dogs_dir=os.path.join(base_dir,'training_set...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:卷积神经网络入门

fromkerasimportlayersfromkerasimportmodelsmodel=models.Sequential()#首层接收2维输入model.add(layers.Conv2D(32,(3,3),activation='relu',input_shape=(28,28,1)))model.add(...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用神经网络预测房价中位数

importpandasaspddata_path='/Users/chenyi/Documents/housing.csv'housing=pd.read_csv(data_path)housing.info()housing.head()housing.describe()housing.hist(bins=50,...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用神经网络实现新闻话题分类

importpandasaspddf=pd.read_json('/Users/chenyi/Documents/News_Category_Dataset.json',lines=True)df.head()categories=df.groupby('category')print("totalcategories...

吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:实现分析电影评论正负能量

fromkeras.datasetsimportimdb#num_words表示加载影评时,确保影评里面的单词使用频率保持在前1万位,于是有些很少见的生僻词在数据加载时会舍弃掉(train_data,train_labels),(test_data,test_labels)=imdb.load_data(num_wor...

吴裕雄--天生自然Python Matplotlib库学习笔记:matplotlib绘图(2)

importnumpyasnpimportmatplotlib.pyplotaspltfig=plt.figure()fig.subplots_adjust(bottom=0.025,left=0.025,top=0.975,right=0.975)plt.subplot(2,1,1)plt.xticks([]),pl...

吴裕雄--天生自然Python Matplotlib库学习笔记:matplotlib绘图(1)

Matplotlib可能是Python2D-绘图领域使用最广泛的套件。它能让使用者很轻松地将数据图形化,并且提供多样化的输出格式。frompylabimport*size=128,16dpi=72.0figsize=size[0]/float(dpi),size[1]/float(dpi)fig=figure(figs...

吴裕雄--天生自然PythonDjangoWeb企业开发:学员管理系统- 前台

开发首页做一个简单的用户提交申请的表单页面。首先在student/views.py文件中编写下面的代码:#-*-coding:utf-8-*-from__future__importunicode_literalsfromdjango.shortcutsimportrenderdefindex(request):wor...