日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

keras随笔-读取IMDB电影数据集

發布時間:2025/3/12 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 keras随笔-读取IMDB电影数据集 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、加載IMDB數據集

# -*- coding: utf-8 -*- """ Created on Wed May 22 13:12:05 2019@author: liuxing @email:lx@lxaipro.com """ from keras.datasets import imdb #每個樣本特征為最多的10000個單詞,每個樣本每個單詞被賦予了一個ID即索引 (trainData,trainLabels),(testData,testLabels)=imdb.load_data(num_words=10000)print(trainData[0]) print(trainLabels[0])




4, 226, 22, 21, 134, 476, 26, 480, 5, 144, 30, 5535, 18, 51, 36, 28, 224, 92, 25, 104, 4, 226, 65, 16, 38, 1334, 88, 12, 16, 283, 5, 16, 4472, 113, 103, 32, 15, 16, 5345, 19, 178, 32]
1

解碼單詞索引,查看評論原文

# -*- coding: utf-8 -*- """ Created on Wed May 22 13:12:05 2019@author: liuxing @email:lx@lxaipro.com """ from keras.datasets import imdb #每個樣本特征為最多的10000個單詞,每個樣本每個單詞被賦予了一個ID即索引 (trainData,trainLabels),(testData,testLabels)=imdb.load_data(num_words=10000)print(trainData[0]) print(trainLabels[0]) wordIndex=imdb.get_word_index() i=0 for (key,value) in wordIndex.items():print("|{}=>{}|".format(key,value),end='')i+=1;if i>5:breakindexWord=dict([(value,key) for (key,value) in wordIndex.items()]) trainWords=' '.join([indexWord.get(i-3,'?') for i in trainData[0]]) print(trainWords)

運行結果如下:

[1, 14, 22, 16, 43, 530, 973, 1622, 1385, 65, 458, 4468, 66, 3941, 4, 173, 36, 256, 5, 25, 100, 43, 838, 112, 50, 670, 2, 9, 35, 480, 284, 5, 150, 4, 172, 112, 167, 2, 336, 385, 39, 4, 172, 4536, 1111, 17, 546, 38, 13, 447, 4, 192, 50, 16, 6, 147, 2025, 19, 14, 22, 4, 1920, 4613, 469, 4, 22, 71, 87, 12, 16, 43, 530, 38, 76, 15, 13, 1247, 4, 22, 17, 515, 17, 12, 16, 626, 18, 2, 5, 62, 386, 12, 8, 316, 8, 106, 5, 4, 2223, 5244, 16, 480, 66, 3785, 33, 4, 130, 12, 16, 38, 619, 5, 25, 124, 51, 36, 135, 48, 25, 1415, 33, 6, 22, 12, 215, 28, 77, 52, 5, 14, 407, 16, 82, 2, 8, 4, 107, 117, 5952, 15, 256, 4, 2, 7, 3766, 5, 723, 36, 71, 43, 530, 476, 26, 400, 317, 46, 7, 4, 2, 1029, 13, 104, 88, 4, 381, 15, 297, 98, 32, 2071, 56, 26, 141, 6, 194, 7486, 18, 4, 226, 22, 21, 134, 476, 26, 480, 5, 144, 30, 5535, 18, 51, 36, 28, 224, 92, 25, 104, 4, 226, 65, 16, 38, 1334, 88, 12, 16, 283, 5, 16, 4472, 113, 103, 32, 15, 16, 5345, 19, 178, 32] 1 |fawn=>34701||tsukino=>52006||nunnery=>52007||sonja=>16816||vani=>63951||woods=>1408|? this film was just brilliant casting location scenery story direction everyone's really suited the part they played and you could just imagine being there robert ? is an amazing actor and now the same being director ? father came from the same scottish island as myself so i loved the fact there was a real connection with this film the witty remarks throughout the film were great it was just brilliant so much that i bought the film as soon as it was released for ? and would recommend it to everyone to watch and the fly fishing was amazing really cried at the end it was so sad and you know what they say if you cry at a film it must have been good and this definitely was also ? to the two little boy's that played the ? of norman and paul they were just brilliant children are often left out of the ? list i think because the stars that play them all grown up are such a big profile for the whole film but these children are amazing and should be praised for what they have done don't you think the whole story was so lovely because it was true and was someone's life after all that was shared with us all

總結

以上是生活随笔為你收集整理的keras随笔-读取IMDB电影数据集的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。