使用请求库,我在以下链接中获得一个页面:https ://pastebin.com/YneDr4id
如何获取写入到 initialState 变量的 Json 对象,以便在 python 代码中进一步使用该对象?
使用请求库,我在以下链接中获得一个页面:https ://pastebin.com/YneDr4id
如何获取写入到 initialState 变量的 Json 对象,以便在 python 代码中进一步使用该对象?
有一个服务器具有以下特点:
处理器:Intel Xeon E5-2430L v2,2.8 Ghz Turbo,6 核,12 线程
内存:16GB
带宽:1Gbps
硬盘大小:1TB
问题:
大约有多少名片网站(5-10 页)每天访问 <= 100 人将能够掌握此服务器?
需要编写正则表达式来搜索文本中的 TIN。
可能文本的第一个示例:
Lorem Ipsum 是经常用于印刷和网页设计的鱼文本。自 16 世纪初以来,Lorem Ipsum 一直是拉丁文本的标准“鱼”。当时,一位未命名的打印机创建了大量字体大小和形状,使用 Lorem Ipsum 打印样本。Lorem Ipsum TIN 3603006880 不仅成功地存活了五个世纪而没有发生明显变化,而且还涉足电子设计领域。在 60 年代出版了带有 Lorem Ipsum 模式的 Letraset 表格,以及最近通过 Aldus PageMaker 等布局程序(在其模板中使用 Lorem Ipsum),它已在现代得到普及。
可能文本的第二个示例:
Lorem Ipsum-этотекст-"рыба",частоиспользуемыйвпечатии вэб-дизайне.LoremIpsumявляется стандартной "рыбой" для текстов на латиницесначалаXVIвека.Втовремянекийбезымянныйпечатник создалбольшуюколлекциюразмеровиформшрифтовиспользуяLorem Ipsumдляраспечаткиобразцов.LoremIpsumИНН3603006880нетолько успешнопережилбеззаметныхизмененийпятьвеков,ноиперешагнулв электронный дизайн.Егопопуляризациивновоевремяпослужили публикациялистовLetrasetсобразцамиLoremIpsumв60-хгодахи,в болеенедавнеевремя,программыэлектроннойвёрсткитипаAldus PageMaker,вшаблонахкоторыхиспользуетсяLoremIpsum.
添加:
TIN 始终具有 10 位的固定长度。
我想创建一个用于解压缩 rar 档案的程序。我知道有现成的解决方案,但没有一个完全适合我。如何开始攻击rar格式?以前从来没有做过这样的事情。在这种情况下应该怎么做?分享你的经验。
需要从 .doc 文件中提取文本。我如何以及使用什么库来完成这项任务?
有以下文字:
2019年 3 月 12 日 10:00(6 天)关于一些非常有趣的事情的其他文本。
一个任务:
正则表达式必须从文本中提取示例中以粗体突出显示的片段。(日期可以是任何日期)
时间的文本表示有以下选项:
12.03.2019 в 13:00
14.02.2019 12:00
一个任务:
需要将测试时间格式转换为 Unix epochs
使用以下行:
loaded_model.predict(tokenize_text)
我得到这样的神经网络预测:
[[1.4275383e-02 5.4952472e-01 4.3477431e-01 4.6290222e-04 7.9817160e-05
7.9108047e-04 9.1869697e-05]]
这是什么?是输入文本与每个类别相关的概率,还是其他?
如何进行这样的回答?
PS我使用categorical_crossentropy
分类。
有一个训练有素的神经网络。需要在新数据集上重新训练它。
网络架构:
early_stop = EarlyStopping(monitor='val_acc', min_delta=0.001,
patience=3, verbose=1, mode='auto')
chkpt = ModelCheckpoint('architecture.hdf5',
monitor='val_loss',
verbose=1,
save_best_only=True,
mode='auto')
callbacks = [early_stop, chkpt]
model = Sequential()
model.add(Embedding(max_features, 32))
model.add(SpatialDropout1D(0.2))
model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2))
model.add(Dense(num_classes, activation="softmax"))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(x_train, y_train, batch_size=128, epochs=50,
validation_data=(x_test, y_test), verbose=1, callbacks=callbacks)
PS: 如何改进这个神经网络的架构?
数据集大小: 350.000 千个示例
类别数: 95
神经网络架构:
model = Sequential()
model.add(Embedding(max_features, 32))
model.add(SpatialDropout1D(0.2))
model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2))
model.add(Dense(len(labels_lexicon), activation="softmax")
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(x_train, y_train, batch_size=128, epochs=15,
validation_data=(x_test, y_test), verbose=2)
scores = model.evaluate(x_test, y_test,
batch_size=128)
问题: 训练的最佳“epoch”数是多少?
有以下数组:
["1", "2", "3", "4", "5", "6"]
问题:
如何在"2"
和之间显示元素"5"
?
我需要训练一个神经网络来识别特定主题(例如体育)的文本。在这种情况下,神经网络应该预测文本的主题是否与运动有关。以下不清楚:
编码:
model = Sequential()
model.add(Embedding(max_features, 32))
model.add(SpatialDropout1D(0.2))
model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2))
model.add(Dense(num_classes, activation="sigmoid"))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(x_train, y_train, batch_size=256, epochs=15,
validation_data=(x_test, y_test), verbose=2)
scores = model.evaluate(x_test, y_test,
batch_size=256)
是否有用于文本分类的更好/高效的神经网络架构?
有以下熊猫DataFrame
:
df = pd.DataFrame(columns=['labels', 'texts'])
如何向此添加新条目DataFrame
?
我写了一个神经网络脚本,或者更确切地说是准备输入数据的一部分。但我不确定我是否做对了所有事情,以便模型可以正确学习。我真的需要知道的人的意见。
编码:
import sklearn
import numpy as np
from collections import Counter
from keras.models import model_from_json
from keras.preprocessing import sequence
from sklearn.model_selection import train_test_split as tts
labels_lexicon = ['_label_0', '_label_1', '_label_2'] # список категорий
def get_data_from_the_file():
labels, descriptions, lexicon, lexicon_base = [], [], [], []
for i, line in enumerate(open('testtext.txt', 'r', encoding='utf8', errors='ignore')):
content = line.split()
labels.append([content[0]])
descriptions.append(content[1:])
lexicon_base += content[1:]
count_lexicon = Counter(lexicon_base).most_common(5000)
for count_item in count_lexicon:
lexicon.append(count_item[0])
return labels, descriptions, lexicon
labels, descriptions, lexicon = get_data_from_the_file()
def get_descriptions_to_index(lexicon):
cache = {}
word2index = {}
for i,word in enumerate(lexicon):
if cache.get(word) == None:
cache[word] = i
word2index[word] = i
return word2index
word2index = get_descriptions_to_index(lexicon)
def get_labels_to_index(labels_lexicon):
cache = {}
labels2index = {}
for i,word in enumerate(labels_lexicon):
if cache.get(word) == None:
cache[word] = i
labels2index[word] = i
return labels2index
labels2index = get_labels_to_index(labels_lexicon)
list_of_tokenize_descriptions = []
list_of_tokenize_labels = []
for descriptions_arrays in descriptions:
prepare_list_of_tokenize_descriptions = []
for descriptions_piece in descriptions_arrays:
if word2index.get(descriptions_piece) != None:
prepare_list_of_tokenize_descriptions.append(word2index[descriptions_piece])
list_of_tokenize_descriptions.append(prepare_list_of_tokenize_descriptions)
for labels_arrays in labels:
prepare_list_of_tokenize_labels = []
for labels_piece in labels_arrays:
if labels2index.get(labels_piece) != None:
prepare_list_of_tokenize_labels.append(labels2index[labels_piece])
list_of_tokenize_labels.append(prepare_list_of_tokenize_labels)
x_matrix_list = []
y_matrix_list = []
for i in range(len(list_of_tokenize_descriptions)):
matrix_i = np.zeros((len(lexicon)),dtype=int)
line = list_of_tokenize_descriptions[i]
for index in line:
matrix_i[index] = 1
x_matrix_list.append(matrix_i)
for i in range(len(list_of_tokenize_labels)):
matrix_i = np.zeros((len(labels_lexicon)),dtype=int)
line = list_of_tokenize_labels[i]
for index in line:
matrix_i[index] = 1
y_matrix_list.append(matrix_i)
x_train, x_test, y_train, y_test = tts(np.array(x_matrix_list), np.array(y_matrix_list), test_size=0.3)
这是数据集的链接。
在神经网络的输入端,我提交了一个文本,它应该分为 3 类。得到以下回复:
[[0.4575766 0.45049337 0.45947695]
[0.43210754 0.41918626 0.43070686]
[0.43210754 0.41918626 0.43070686]
...
[0.4575766 0.45049337 0.45947695]
[0.4575766 0.45049337 0.45947695]
[0.4575766 0.45049337 0.45947695]]
长度等于文本中单词数的数组列表。
问题:
如何进一步处理这些数据?
完整脚本代码: https ://pastebin.com/ufJZE4Jr
该脚本将行一一添加到文件中。问题是行之间有隐藏的空间。
例子:
_label_0 Оказание дополнительных реабилитационных услуг по реабилитации детей-инвалидов вследствие детского церебрального паралича и других патологий методом иппотерапии
_label_0 Строительство НИИ Детской онкологии и гематологии РОНЦ им. Н.Н. Блохина РАМН по адресу: г. Москва, Каширское шоссе, дом 24 (Поставка медицинского оборудования и мебели)
_label_0 Выполнение работ по ремонту имеющегося у Заказчика медицинского оборудования производства фирмы Maquet GmbH, Германия
_label_0 Поставка перчаток медицинских в 2019 году
假设
我认为问题是隐藏的Unicode字符
写入文件的部分代码:
str_to_write = str(url[1]) + " " + str(description_item.getText()) + "\r\n"
if str_to_write != " ":
with open("fortest.txt", "a", encoding='utf8') as f:
f.write(str_to_write)