91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

深度學(xué)習(xí)算法實(shí)踐-電子工業(yè)出版社-吳岸城-2017年1月-隨書(shū)源碼

資源截圖

代碼片段和文件信息

#?-*-?coding:utf-8?-*-
import?os
os.environ[‘KERAS_BACKEND‘]?=?“theano“
#?os.environ[‘THEANO_FLAGS‘]?=?“device=cpu“
from?keras.models?import?Sequential
from?keras.layers.core?import?Dense?Activation
from?keras.layers.recurrent?import?LSTM
from?keras.layers.wrappers?import?TimeDistributed?Bidirectional
from?keras.layers?import?FlattenLambdaK
from?keras.layers.embeddings?import?embedding
from?keras.layers.pooling?import?MaxPooling2D?GlobalMaxPooling2DMaxPooling1D
from?keras.preprocessing.text?import?Tokenizer
from?keras.preprocessing.sequence?import?pad_sequences
from?keras.layers?import?MergeDropout
from?keras.datasets?import?imdb
import?numpy?as?np
#?from?keras.utils?import?plot_model
from?keras.utils.visualize_util?import?plot

from?keras.preprocessing?import?sequence

def?text_feature_extract_model1(embedding_size=128?hidden_size=256):
????‘‘‘
????this?is?a?model?use?normal?Bi-LSTM?and?maxpooling?extract?feature

????examples:
這個(gè)貨很好,很流暢?[??1.62172219e-05]
這個(gè)東西真好吃,?[??1.65377696e-05]
服務(wù)太糟糕味道差?[?1.]
這個(gè)貼花的款式好看?[??1.76498161e-05]
看著不錯(cuò),生產(chǎn)日期也是新的是16年12月份的,就是有點(diǎn)小貴?[??1.59666997e-05]
一股淡淡的腥味。每次喝完都會(huì)吃一口白糖?[?1.]
還沒(méi)喝,不過(guò),看著應(yīng)該不錯(cuò)喲?[??1.52662833e-05]
用來(lái)看電視還是不錯(cuò)的,就是有些大打字不習(xí)慣,要是可以換輸入法就好了!?[?1.]
嗯,中間出了點(diǎn)小問(wèn)題已經(jīng)聯(lián)系蘋(píng)果客服解決了,打游戲也沒(méi)有卡頓,總體來(lái)講還不錯(cuò)吧!?[??1.52281245e-05]
下軟件下的多的時(shí)候死了一回機(jī),強(qiáng)制重啟之后就恢復(fù)了。?[?1.]
東西用著還可以很流暢!?[??1.59881820e-05]


????:return:
????‘‘‘
????model?=?Sequential()
????model.add(embedding(input_dim=max_features
????????????????????????output_dim=embedding_size
????????????????????????input_length=max_seq))
????model.add(Bidirectional(LSTM(hidden_size?return_sequences=True)))
????model.add(TimeDistributed(Dense(embedding_size/2)))
????model.add(Activation(‘softplus‘))
????model.add(MaxPooling1D(5))
????model.add(Flatten())
????#?model.add(Dense(2048?activation=‘softplus‘))
????#?model.add(Dropout(0.2))
????model.add(Dense(1?activation=‘sigmoid‘))

????model.compile(loss=‘binary_crossentropy‘?optimizer=‘a(chǎn)dam‘?metrics=[‘a(chǎn)ccuracy‘])
????model.summary()
????plot(model?to_file=“text_feature_extract_model1.png“?show_shapes=True)
????return?model

if?__name__?==?“__main__“:
????#prepare?y?1?negtive?0?postive
????y?=?[]

????txt_path?=?‘../data/corpus/reviews/‘

????with?open(txt_path+‘1_point.txt‘?‘rb‘)?as?fp:
????????lines?=?fp.readlines()

????len_temp_lines?=?len(lines)
????for?i?in?range(len(lines)):
????????y.append(1)

????with?open(txt_path+‘5_point.txt‘?‘rb‘)?as?fp:
????????lines?+=?fp.readlines()

????for?i?in?range(len(lines[len_temp_lines:])):
????????y.append(0)

????def?create_dict():
????????dict?=?open(txt_path+‘1_point.txt‘?‘rb‘).read()
????????#?dict?+=?open(txt_path?+?‘2_point.txt‘?‘rb‘).read()
????????dict?+=?open(txt_path+‘5_point.txt‘?‘rb‘).read()
????????dict_list?=?set(list(dict.decode(‘utf8‘)))
????????dicts?=?{}
????????for?i?d?in?enumerate(dict_list):
????????????dicts[d]?=?i
????????return?dicts

????def?create_X(lines):
????????len_seq?=?[]
????????dicts?=?create_dict()
????????sequences?=?[]
????????for?line?

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\
?????文件???????????7??2017-04-20?11:24??Book_DeepLearning_Practice-master\.gitignore
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\algorithm\
?????文件????????6086??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\algorithm\RNN-CNN_feature_extract.py
?????文件???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\algorithm\__init__.py
?????文件???????71891??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\algorithm\text_feature_extract_model1.png
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\data\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\data\corpus\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\data\corpus\reviews\
?????文件????16765967??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\data\corpus\reviews\1_point.txt
?????文件????14183087??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\DeepTextClf\data\corpus\reviews\5_point.txt
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\提取和選擇\
?????文件???????12292??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\提取和選擇\answer_find_out.py
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\爬取\
?????文件???????38276??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\爬取\fromSE.py
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\相似提取答案\
?????文件????????4433??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\相似提取答案\Compress.py
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\蘊(yùn)含\
?????文件????????8415??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\dialogue\蘊(yùn)含\textual_entailment.py
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\mail\
?????文件????????1789??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\mail\mail_classily.py
?????文件????????4660??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\mail\stopwords.txt
?????文件?????????452??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\mail\text_preprocess.py
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\sentiment\
?????目錄???????????0??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\sentiment\LSTM\
?????文件????????5410??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\sentiment\LSTM\extract_feature.py
?????文件?????????931??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\sentiment\LSTM\lstm_model.py
?????文件?????????340??2017-04-20?11:24??Book_DeepLearning_Practice-master\2_Chapter\sentiment\LSTM\test_lstm.py
............此處省略64個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源