基于python ttkbootstarp的密钥生成器

密钥生成器 密钥生成器! 阅读详情

App key和App Secret

App key简称API接口验证序号,是用于验证API接入合法性的。接入哪个网站的API接口,就需要这个网站允许才能够接入,如果简单比喻的话:可以理解成是登陆网站的用户名。

App Secret简称API接口密钥,是跟App Key配套使用的,可以简单理解成是密码。

App Key 和 App Secret 配合在一起,通过其他网站的协议要求,就可以接入API接口调用或使用API提供的各种功能和数据。

比如淘宝联盟的API接口,就是淘宝客网站开发的必要接入,淘客程序通过API接口直接对淘宝联盟的数据库调用近亿商品实时数据。做到了轻松维护,自动更新。

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# pyinstaller --clean -w  -F -i favicon.ico app_gen.py -n 密钥生成器

import datetime
import hashlib
import os.path
import random
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from tkinter import filedialog as tkFileDialog
from ttkbootstrap.dialogs import Messagebox
import pyperclip
import base64
from icon import img

# 获取当前工作目录
path = os.getcwd()
# 默认文件名
filename = 'id_rsa.txt'

# 实例化创建应用程序窗口
root = ttk.Window(
    title="密钥生成器V1.0",  # 设置窗口的标题
    themename="litera",  # 设置主题
    minsize=(800, 400),  # 窗口的最小宽高
    maxsize=(1920, 1080),  # 窗口的最大宽高
    resizable=(True, True),  # 设置窗口是否可以更改大小
    alpha=1.0,  # 设置窗口的透明度(0.0完全透明)
)


def setIcon(root):
    tmp = open("tmp.ico", "wb+")
    tmp.write(base64.b64decode(img))  # 写入到临时文件中
    tmp.close()
    root.iconbitmap("tmp.ico")  # 设置图标
    os.remove("tmp.ico")


setIcon(root)

root.place_window_center()

root.wm_attributes('-topmost', 1)  # 让窗口位置其它窗口之上

ENTRY_WIDTH = 320
LABEL_LEFT_X = 160
ENTRY_LEFT_X = 280

# 在窗口上创建组件(AppId)
APP_ID_Y = 60
labeName = ttk.Label(root, text='AppId:', font=("微软雅黑", 16), bootstyle=INFO)
labeName.place(x=LABEL_LEFT_X, y=APP_ID_Y, width=125, height=40)
varId = ttk.StringVar(root, value='')
entryName = ttk.Entry(root, width=200, textvariable=varId, bootstyle=INFO)
entryName.place(x=ENTRY_LEFT_X, y=APP_ID_Y, width=ENTRY_WIDTH, height=40)


def callback1(event=None):
    if(varId.get() != ''):
        pyperclip.copy(varId.get())
        Messagebox.show_info(title='温馨提示', message='复制成功!')


buttonCopy1 = ttk.Button(
    root, text='复制', bootstyle=(PRIMARY, "outline-toolbutton"), command=callback1)
buttonCopy1.place(x=ENTRY_LEFT_X+ENTRY_WIDTH+20,
                  y=APP_ID_Y, width=60, height=40)


# 在窗口上创建组件(AppKey)
APP_KEY_Y = 120
labeName = ttk.Label(root, text='AppKey:', bootstyle=INFO, font=("微软雅黑", 16))
labeName.place(x=LABEL_LEFT_X, y=APP_KEY_Y, width=125, height=40)
varKey = ttk.StringVar(root, value='')
entryPwd = ttk.Entry(root, width=120, textvariable=varKey)
entryPwd.place(x=ENTRY_LEFT_X, y=APP_KEY_Y, width=ENTRY_WIDTH, height=40)


def callback2(event=None):
    if(varKey.get() != ''):
        pyperclip.copy(varKey.get())
        Messagebox.show_info(title='温馨提示', message='复制成功!')


buttonCopy1 = ttk.Button(
    root, text='复制', bootstyle=(PRIMARY, "outline-toolbutton"), command=callback2)
buttonCopy1.place(x=ENTRY_LEFT_X+ENTRY_WIDTH+20,
                  y=APP_KEY_Y, width=60, height=40)


# 在窗口上创建组件(AppSecret)
APP_SECRET_Y = 180
labeName = ttk.Label(root, text='AppSecret:',
                     bootstyle=INFO, font=("微软雅黑", 16))
labeName.place(x=LABEL_LEFT_X, y=APP_SECRET_Y, width=125, height=40)
varSecret = ttk.StringVar(root, value='')
entrySecret = ttk.Entry(root, width=120, textvariable=varSecret)
entrySecret.place(x=ENTRY_LEFT_X, y=APP_SECRET_Y, width=ENTRY_WIDTH, height=40)


def callback3(event=None):
    if(varSecret.get() != ''):
        pyperclip.copy(varSecret.get())
        Messagebox.show_info(title='温馨提示', message='复制成功!')


buttonCopy1 = ttk.Button(
    root, text='复制', bootstyle=(PRIMARY, "outline-toolbutton"), command=callback3)
buttonCopy1.place(x=ENTRY_LEFT_X+ENTRY_WIDTH+20,
                  y=APP_SECRET_Y, width=60, height=40)

OPENID_PREFIX = "sddf"


def create_app_id() -> str:
    """
           生成开放接口openId,使用sddf作为统一前缀
           :return: 返回值名: 返回值说明
        """
    now = datetime.datetime.now().timestamp()
    app_id = hashlib.md5(str(now).encode('utf-8'))
    return OPENID_PREFIX + app_id.hexdigest()[4:]


def create_app_key(module='', length=8) -> str:
    """
       函数说明
       :param module: 模块名称,用作生成app_key的"盐值"
       :param length: 模块名称,用作生成app_key的长度,默认8位
       :return: app_key: 业务key
    """
    source_letters = module + \
        "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    str_list = [random.choice(source_letters) for i in range(length)]
    app_key = ''.join(str_list)
    return app_key


def create_app_secret(salt: str, length=40) -> str:
    """
          函数说明
          :param salt: 模块名称,用作生成app_key的"盐值"
          :param length: 模块名称,用作生成app_key的长度,默认8位
          :return: app_secret: 密钥
       """
    source_letters = salt + "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    str_list = [random.choice(source_letters) for i in range(length)]
    app_secret = ''.join(str_list)
    return app_secret


# 生成按钮事件处理函数
def gen():
    varId.set(create_app_id())
    varKey.set(create_app_key())
    varSecret.set(create_app_secret(create_app_id()))


BUTTON_FUN_Y = 260
BUTTON_FUN_H = 30
# 创建按钮组件,同时设置按钮事件处理函数
# 参数解释:  text='生成'文本内容      activeforeground='#ff0000'按下按钮时文字颜色     command=login关联的函数
buttonOk = ttk.Button(
    root, text='生成', bootstyle=SUCCESS, command=gen)
buttonOk.place(x=270, y=BUTTON_FUN_Y, width=80, height=BUTTON_FUN_H)

# 创建保存组件,同时设置按钮事件处理函数
file_opt = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
options['initialdir'] = path
options['initialfile'] = filename
options['parent'] = root
options['title'] = '请选择保存路径'


def saveToFile():
    """Returns an opened file in write mode.
    This time the dialog just returns a filename and the file is opened by your own code.
    """
    if varId.get() == '' or varKey.get() == '' or varSecret.get() == '':
        Messagebox.show_error(message='请生成密钥')
        return
    # get filename
    filename = tkFileDialog.asksaveasfilename(**file_opt)

    # open file on your own
    if filename:
        app_id = "AppId: " + varId.get()
        app_key = "AppKey: " + varKey.get()
        app_secret = "AppSecret: " + varSecret.get()
        list = [app_id, app_key, app_secret]
        with open(filename, "w", encoding="utf-8") as fw:  # 可以写入txt文件
            for i in list:
                fw.write(i + "\n")
        Messagebox.show_info(message='写入成功!')


buttonSave = ttk.Button(
    root, text='保存', bootstyle=SUCCESS, command=saveToFile)
buttonSave.place(x=420, y=BUTTON_FUN_Y, width=80, height=BUTTON_FUN_H)


# 清空按钮的事件处理函数


def clear():
    # 清空生成的数据
    varId.set('')
    varKey.set('')
    varSecret.set('')


buttonClear = ttk.Button(root, text='清空', bootstyle=SUCCESS, command=clear)
buttonClear.place(x=550, y=BUTTON_FUN_Y, width=80, height=BUTTON_FUN_H)

root.mainloop()

打包icon文件需要用到的工具类:

# 这段程序可将图标gen.ico转换成icon.py文件里的base64数据
import base64
open_icon = open("favicon.ico", "rb")  # favicon.icon为你要放入的图标
b64str = base64.b64encode(open_icon.read())  # 以base64的格式读出
open_icon.close()
write_data = "img=%s" % b64str
f = open("icon.py", "w+")  # 将上面读出的数据写入到icon.py的img数组中
f.write(write_data)
f.close()

效果如下:

DES加密和解密工具(亲测可用) 可以指定不同的密钥进行加密操作,增强加密性能。加密和解密代码如下: package com.ywx.test.security; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; /** * DES加密和解密工具,可以对字符串进行加密和解密操作. */ public class Test1 { /** 字符串默认键值 */ privat... 阅读详情

相关推荐

Powershell 7.x中UTF-8环境中文乱码解决办法

Powershell7 中文乱码问题解决

shadow_zed的博客 8417

outline使用

outline

随手写下笔记和感悟 7万+

Outline-Client.rar

Outline-Client.ext是一款比较好用的网络代理客户端软件,配套的有服务器软件,建议配套一起使用

Windows 10 密钥分享

Windows 10 Technical Preview for Enterprise:   KEY:PBHCJ-Q2NYD-2PX34-T2TD6-233PK   http://technet.microsoft.com/zh-CN/evalcenter/dn781239.aspx   Windows 10 Technical Preview:   KEY:NKJFK-GPHP7-G8C

3万+

万能破解资源

这是本人收藏了多年的序列号、注册码、密钥。能轻松破解我们学习,生活中许多软件。让大家免费使用。以前该资源我是不分享的,现在分享给大家。所以下载需要一定的资源分,下载后请大家好好珍惜。

api-key-generator:使用 Python 的简单 API 密钥生成器

api-key-生成器 使用 Python 的简单 API 密钥生成器 开发环境 操作系统:Windows 8.1 64 位 工具: Python 2.7.9 MongoDB 3.0.2(从下载 64 位安装程序) pymongo ( pip install pymongo ) 参数解析 吉特 用法 您可以将此应用程序用作模块和命令行实用程序。 作为模块 import api_key_gen apikey = api_key_gen . APIKeyGenerator () key = apikey . generate () print key 作为命令行实用程序 运行以下命令寻求帮助 $ python api_key_gen.py -h or --help 创建池: $ python api_key_gen.py -s 100 -s 池大小,默认为 10

谷歌地球下载 Outline密钥生成 问题备忘录

谷歌地球下载及使用总是指引,Outline使用问题

yezichen2的专栏 1万+

outline-bots

OutlineBot 先决条件 电报机器人和电子邮件响应者之间的共同点: 您应该在云提供商中拥有一个具有足够权限的用户来创建所需的资源 在Outline Distribution服务器中创建的用户和密码(API密钥/令牌) 用户应具有以下权限 发行应用: OutlineUser:查看,添加 VPN用户:查看,更改,添加,删除 问题:查看 服务器应用程序: OutlineServer:视图 基于Unix的系统 需要二进制(命令)envsubst。 安装相关的软件包。 Ubuntu示例: apt-get更新 apt-get install gettext-base 云中所需的资源: 提供repo中的脚本aws/aws_resources_setup.sh作为示例。 可用于在Amazon Cloud中设置资源 资源: 无服务器功能运行所需的角色或权限 无服务器功能 电报机器人: 在

outline

定义和用法 outline (轮廓)是绘制于元素周围的一条线,位于边框边缘的外围,可起到突出元素的作用。 注释:轮廓线不会占据空间,也不一定是矩形。 outline 简写属性在一个声明中设置所有的轮廓属性。 可以按顺序设置如下属性: outline-color outline-style outline-width<!DOCTYPE html PUBLIC "-//W3C//DTD X

一心一意码代码 1万+

Wireshark、Fiddler、Charles 三款抓包工具的本质差异与选型指南

抓包工具是网络调试与接口分析的基础能力,其核心在于理解OSI模型分层原理——不同工具工作在不同协议层级,解决不同维度问题。Wireshark面向网络层(L2/L3),可捕获原始数据帧与TCP握手细节,适用于DNS异常、丢包重传等底层问题定位;Fiddler和Charles则工作在应用层(L7),作为HTTP(S)代理实现HTTPS解密、请求改写与弱网模拟,是API调试与移动端测试的首选。技术价值体现在:精准匹配问题域(如证书固定需Fiddler脚本绕过,iOS调试依赖Charles证书信任链),避免‘用显微

weixin_28831341的博客 253

深入浅出PWM:用示波器带你理解占空比与滤波效果

本文通过示波器实测,深入浅出地解析了PWM(脉宽调制)的核心原理。从占空比与平均电压的关系入手,详细演示了RC及有源滤波器如何将数字方波“翻译”为平滑模拟电压,并探讨了PWM-DAC的精度、响应速度等关键设计考量,为硬件调试与电路设计提供了实用的实践指导。

weixin_29292431的博客 343

MarkDown Pad2 输入密钥,免费分享

由博主 guo_wen_qiang 分享 https://blog.youkuaiyun.com/guo13313/article/details/66082507   问题描述 Windows 10系统,安装 MarkdownPad 2,打开markdown并书写相关内容时遇到了html 渲染错误(缺少component),右侧视图直接显示 “This view has crashed”的问题...

nbxzkok的专栏 6473

ThinkPad T14 Gen 2与T14P系列对比

表格您的需求推荐机型日常办公、出差、文档处理、视频会议✅(够用、轻便、便宜)视频剪辑、3D建模、编程编译、AI训练、高色准设计✅(性能强、屏幕好、扩展佳)想要未来 5 年不换机✅T14p预算低于 5000 元✅T14 Gen 2(或考虑 T14 Gen 3/4)T14p 2025 款 ≠ 小改款,而是架构级升级它从“高性能笔记本”进化为“AI 移动工作站”,核心差异在于NPU + Ultra 平台 + 全面屏显 + 超长续航。如果您从事AI 开发、视频创作、工程仿真、多任务编程。

tecoes的博客 2733

outline创建使用

--outline现在已经被sql profile替代,但还是学习下 -- 准备工作 : 赋权限:grant create any outline to aiki; SQL> show parameter stored NAME                                 TYPE        VALUE ---------------------------

N 2431

OLLAMA_HOST环境变量设置全攻略:从127.0.0.1到局域网共享的完整配置

本文详细解析了OLLAMA_HOST环境变量的核心作用与配置方法,指导用户如何将Ollama服务从仅限本机访问(127.0.0.1)扩展到局域网共享。文章涵盖了macOS、Linux、Windows三大平台的实战配置步骤,并提供了安全加固、性能优化及常见故障排查方案,是解决多设备协作访问本地AI模型的完整指南。

weixin_28455801的博客 1894

LDRA Testbed(TBrun)软件单元测试_实例讲解(对多次调用的函数打桩)

在之前的文章《LDRA Testbed(TBrun)软件单元测试_操作指南》中,已经讲解了如何使用TBrun进行软件单元测试的基本操作步骤。本篇文章将结合实例进一步讲解被测函数中包含多次调用其他函数时,如何对其打桩来实现测试目的(详细的操作流程本文不再重述,若有不清楚的,可以结合之前的操作指南一起来看)。本文以一个被测函数作为示例,讲解了如何使用Testbed(TBrun)对涉及到多次调用其他函数的被测函数进行单元测试。本文的示例可能比较简单,但是思路、方法和流程都是通用的,希望对大家有所帮助。

文章主要涉及嵌入式软件开发、测试、项目管理等,欢迎交流,共同进步。 1461

生成微信API v3密钥

微信生成APIV3秘钥

sinat_36891648的博客 3303

2026华为OD机试(JavaScript)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,JavaScript实现。

MISAYAONE的博客 8万+

Outline使用Authelia实现本地认证

通过 Authelia 的 OIDC 协议,让 Outline 实现本地化认证。

wbsu2004的博客 6365

华为OD机考双机位C卷 - 螺旋数字矩阵 (Java & Python& JS & C/C++ & GO )

华为OD机考双机位C卷 - 数字螺旋矩阵(OD上机考试双机位C卷)。提供在线OJ刷题。Java、C++、Python、GO语言、C语言、JavaScript题解,并提供完整思路讲解。

算法大师! 3215

布尔可满足性问题(SAT)深度研究

布尔可满足性问题(Boolean Satisfiability Problem, SAT)是计算机科学和数理逻辑中的一个核心决策问题。其定义为:对于一个给定的布尔逻辑公式,判断是否存在一组对其变量的真值赋值(即,为每个变量指定真 (True) 或假 (False)),使得该公式的最终计算结果为真。如果存在这样的赋值,则称该布尔公式是可满足的 (satisfiable);否则,称其为不可满足的 (unsatisfiable)。

步子哥的博客 493

python:secrets --- 生成管理密码的安全随机数

python:secrets --- 生成管理密码的安全随机数

FuncPlotCalc 1360

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python 文本框关联_python之UI编程(ttk)——控件之间关联(一个文本框的数值变化,引起另一个文本框变化)...

目标:在Python的UI编程环境中,实现控件之间的关联。本例中窗口中有三个文本框,其中v1和v2是输入,第三个文本框的值等于v1和v2之和。编程环境:win10、Python3.7.6说明:1. 为主类设置三个StringVar类型的属性 v1、v2和v3。v1和v2是输入,v3是输出。v3 = v1 + v22. 对v1和v2设置事件跟踪,回调函数为changeValue,代码:v1.trac...

weixin_35544017的博客 700

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

产品密钥生成器

可以用别人已经写好的现成的开源免费包. String guid=com.opensymphony.util.GUID.generateFormattedGUID(); 参考 http://www.opensymphony.com/oscore/api/com/opensymphony/util/GUID.html http://www.opensymphony.com/oscore/ for

Java技术 2426

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

上一篇: 程序落地部署——python库打包分发
下一篇: Idea-Git与命令行操作合并多次commit为一个/合并提交--图解
shadow_zed
博客等级 码龄10年 6289粉丝 68原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值