python工具软件二进制安全 [2022] 基于NLP的威胁检出引擎 NLP引擎出自于我的一个简单的想法 - 既然人可以通过汇编看出软件是否是病毒 那么机器是否可以通过汇编看呢? 为了让机器能看得懂代码,我首先想到的是非常经典的NLP分类问题,所谓的NLP分类问题,就是训练的时候给一堆词语+词频,推理的时候先把句子中的词语分出来,再然后计算这些词语的词频,最后得出这条句子属于什么类别的结论 阅读全文 2022-03-17 huoji 1 条评论
python一线开发 [2021]从0开始的tensorflow2.0 (二) 上一节 [[2021]从0开始的tensorflow2.0 (一)](https://key08.com/index.php/2021/07/04/1239.html "[2021]从0开始的tensorflow2.0 (一)") 说了基本的逻辑回归操作,实际上所有的一些东西都能被提取特征然后做文本二分类,基本上都是这个套路,现在来说说常见的图像处理 - 卷积 请注意 我们今天只讨论处理后的图像,实际上,**图像识别部分最难的部分就仅仅是图像处理仅此而已,但是我们今天不讨论图像处理** 一个标准的网络由三个部分组成 卷积层 池化层 全连接层 ## 卷积核  阅读全文 2021-07-06 huoji 0 条评论
python一线开发 [2021]手撸机器学习入门之jaya算法 总所周知,所谓机器学习就是一个解方程给x求y的过程罢了. 这是一篇入门的算法代码,又叫做jaya算法(不是java!!!),网上没什么资料,以下是自己python写的. ```python import math import random import matplotlib.pyplot as plt import numpy as np g_group_size = 5000 g_var_weight = 2 g_max_iteration = 100 g_array_f = [0 for i in range(0, g_group_size)] g_array_best = [0 for i in range(0, g_group_size)] g_array_worst = [0 for i in range(0, g_group_size)] g_array_pop_new = [[0 for i in range(0, g_var_weight)] for i in range(0, g_group_size)] #g_number_a = -2 * math.pi #g_number_b = 2 * math.pi #g_number_a = -5.12 #g_number_b = 5.12 g_number_a = -100 g_number_b = 100 g_result = [] array_pop = [[0 for i in range(0, g_var_weight)] for i in range(0, g_group_size)] def fn_objective(pArray): result = 0 for i in range(0, g_var_weight): # result += pArray[i] * pArray[i] # result += math.sin(pArray[i]) * math.pow(math.e, math.pow(1 - math.cos(result), 2)) + math.cos(result) * math.pow(math.e, math.pow(1 - math.sin(pArray[i]), 2)) + math.pow(pArray[i] - result, 2) # result += -(1 + math.cos(12 * math.sqrt(math.pow(pArray[i], 2) + math.pow(result, 2)))) / (0.5 * (math.pow(pArray[i], 2) + math.pow(result, 2)) + 2) result += math.pow(pArray[i], 2) + 2 * math.pow(result, 2) - 0.3 * math.cos(3 * math.pi * pArray[i]) - 0.4 * math.cos(4 * math.pi * result) + 0.7 return result def fn_clean_array(pArray): for i in range(0, g_group_size): for z in range(0, g_var_weight): if pArray[i][z] < g_number_a: pArray[i][z] = g_number_a if pArray[i][z] > g_number_b: pArray[i][z] = g_number_b return pArray for i in range(0, len(array_pop)): for z in range(0, len(array_pop[i])): array_pop[i][z] = random.uniform(g_number_a, g_number_b) g_array_f[i] = fn_objective(array_pop[i]) print("array_pop: ") print(array_pop) print("g_array_f: ") print(g_array_f) iter_num = 1 min_index = 0 max_index = 0 while iter_num <= g_max_iteration: min_value = min(g_array_f) min_index = g_array_f.index(min_value) - 1 g_array_best = array_pop[min_index] max_value = max(g_array_f) max_index = g_array_f.index(max_value) - 1 g_array_worst = array_pop[max_index] for i in range(0, g_group_size): for z in range(0, g_var_weight): wrost_number = g_array_worst[z] - math.fabs(array_pop[i][z]) best_number = g_array_best[z] - math.fabs(array_pop[i][z]) g_array_pop_new[i][z] = array_pop[i][z] + \ random.random() * best_number - wrost_number g_array_pop_new = fn_clean_array(g_array_pop_new) f_new = 0 for i in range(0, len(g_array_pop_new)): f_new = fn_objective(g_array_pop_new[i]) if f_new < g_array_f[i]: g_array_f[i] = f_new for z in range(g_var_weight): array_pop[i][z] = g_array_pop_new[i][z] min_value = min(g_array_f) min_index = g_array_f.index(min_value) g_array_best = array_pop[min_index] print("min number {} ".format(g_array_f[min_index])) print("x=") print(g_array_best) #g_result.insert(0, g_array_f[min_index]) g_result.append(g_array_f[min_index]) iter_num += 1 x = np.arange(0, len(g_result)) y = np.array(g_result) plt.title("jaya") plt.xlabel("min number") plt.ylabel("y") plt.plot(x, y) plt.show() ``` 请注意有一些公式需要很大的族群范围才能收敛 论文里面的收敛图:  这边的:  阅读全文 2021-05-24 huoji 0 条评论
python一线开发 [2021]一些常见的机器视觉用到的神经网络结构(keras) 收藏一些常见的机器视觉用到的神经网络结构,以后不用自己构造网络了! 这些都咋用呢? 我已经写好祖传代码了: ```python def build_save_model(train_data, test_data): # 构建模型 CBAPD network_model = VGG16() network_model.compile(optimizer='adam', loss=tensorflow.keras.losses.SparseCategoricalCrossentropy( from_logits=False), metrics=['accuracy']) #cp_callback = tensorflow.keras.callbacks.ModelCheckpoint(filepath=checkpoint_save_path,save_weights_only=True,save_best_only=True) # 如果要保存点自己在fit加这个参数 # callbacks=[cp_callback] #checkpoint_save_path = "./checkpoint.ckpt" # if os.path.exists(checkpoint_save_path + '.index'): # print('-------------load the model-----------------') # network_model.load_weights(checkpoint_save_path) network_model.fit(train_data, epochs=100, validation_data=test_data, batch_size=64) network_model.summary() network_model.evaluate(test_data) tensorflow.saved_model.save( network_model, '\\model\\') ``` VGG网络: 阅读全文 2021-02-24 huoji 1 条评论