Skip to content

Instantly share code, notes, and snippets.

@R97416032
R97416032 / fashion.py
Created July 22, 2019 07:34
自动下载Fashio-mnist,构建分类模型(softmax回归)并训练、保存model、预测,tensorboard可视化
import tensorflow as tf
import os
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('data', one_hot=True)
x=tf.placeholder(tf.float32,[None,784])
W=tf.Variable(tf.zeros([784,10]))
b=tf.Variable(tf.zeros([10]))
y=tf.nn.softmax(tf.matmul(x,W)+b)
y_=tf.placeholder("float",[None,10])
@R97416032
R97416032 / Fashion_fashion.py
Created July 22, 2019 07:29
自动下载Fashion-mnist数据集,构建分类模型(softmax回归、cnn)并训练、保存model、预测,tensorboard可视化
import tensorflow as tf
import os
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('data', one_hot=True)
x=tf.placeholder(tf.float32,[None,784])
W=tf.Variable(tf.zeros([784,10]))
b=tf.Variable(tf.zeros([10]))
y=tf.nn.softmax(tf.matmul(x,W)+b)
y_=tf.placeholder("float",[None,10])
@R97416032
R97416032 / Fashion_fashion.py
Created July 22, 2019 07:26
fashion-mnist数据集自动下载,构建分类模型(softmax回归)并训练、保存model、预测。 tensorboard可视化
import tensorflow as tf
import os
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('data', one_hot=True)
x=tf.placeholder(tf.float32,[None,784])
W=tf.Variable(tf.zeros([784,10]))
b=tf.Variable(tf.zeros([10]))
y=tf.nn.softmax(tf.matmul(x,W)+b)
y_=tf.placeholder("float",[None,10])
from tensorflow.examples.tutorials.mnist import input_data
from PIL import Image
import numpy as np
#路径要写全
MNIST_data_folder="D:\MNIST\mnist"
mnist=input_data.read_data_sets(MNIST_data_folder,one_hot=True)
print(mnist.train.images.shape, mnist.train.labels.shape)
print(mnist.test.images.shape, mnist.test.labels.shape)
print(mnist.validation.images.shape, mnist.validation.labels.shape)
@R97416032
R97416032 / tensorflow_boston.py
Created July 20, 2019 07:48
波士顿房价预测
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
num_points=1000
vectors_set=[]
for i in range(num_points):
x1=np.random.normal(0.0,0.55) #横坐标,进行随机高斯处理化,以0为均值,以0.55为标准差
@R97416032
R97416032 / 图像文字识别.py
Created July 19, 2019 07:22
基于百度api实现图像文字识别
import urllib.parse
import urllib.request
import sys
import ssl
import base64
access_token = ''
url = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general?access_token=' + access_token
# 二进制方式打开图文件
f = open(r'C:\Users\R\Desktop\QQ截图20190309100002.png', 'rb')
@R97416032
R97416032 / 抓取糗事百科.py
Created July 19, 2019 07:20
简单的爬虫,抓取笑话
import requests_html
import time
from requests_html import HTMLSession
session=HTMLSession()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
}
file1=open("C:\\Users\\R\\Desktop\\笑话.txt","w",encoding='utf-8')
def get_c(url):
@R97416032
R97416032 / 小猪佩奇.py
Created July 19, 2019 07:19
画出可爱的小猪佩奇
# coding:utf-8
import turtle as t
# 绘制小猪佩奇
# =======================================
t.pensize(4)
t.hideturtle()
t.colormode(255)
t.color((255, 155, 192), "pink")
t.setup(840, 500)