21、TensorFlow教程--- XOR 实现

在本章中,我们将学习如何使用 TensorFlow 实现 XOR。在开始 TensorFlow 中的 XOR 实现之前,让我们先看一下 XOR 表的数值。这将帮助我们理解加密和解密过程。

XOR密码加密方法基本上用于加密难以使用暴力破解方法破解的数据,即通过生成与适当密钥匹配的随机加密密钥。

使用XOR密码的实现概念是定义一个XOR加密密钥,然后对用户尝试加密的指定字符串中的字符执行与此密钥的XOR操作。现在,我们将专注于使用TensorFlow进行XOR实现,如下所示 −

#Declaring necessary modules
import tensorflow as tf
import numpy as np
"""
A simple numpy implementation of a XOR gate to understand the backpropagation
algorithm
"""

x = tf.placeholder(tf.float64,shape = [4,2],name = "x")
#declaring a place holder for input x
y = tf.placeholder(tf.float64,shape = [4,1],name = "y")
#declaring a place holder for desired output y

m = np.shape(x)[0]#number of training examples
n = np.shape(x)[1]#number of features
hidden_s = 2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Knowledgebase

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值