当前位置: 首页 > news >正文

佛山网站建设与设计公司网络营销策略实施的步骤

佛山网站建设与设计公司,网络营销策略实施的步骤,seo网络推广员招聘,网络监控管理系统SVD 是一种矩阵分解和降维的算法,通过分解矩阵找到奇异值,奇异值越大代表特征越重要。公式如下 A U Σ V T A U \Sigma V^T AUΣVT U : 左矩阵 ( m \times m ) Σ \Sigma Σ: 对角奇异值矩阵V:右矩阵( n \times n ) Sklearn 实现 S…

SVD 是一种矩阵分解和降维的算法,通过分解矩阵找到奇异值,奇异值越大代表特征越重要。公式如下

A = U Σ V T A = U \Sigma V^T A=UΣVT

  • U : 左矩阵 ( m × \times × m )
  • Σ \Sigma Σ: 对角奇异值矩阵
  • V:右矩阵( n × \times × n )

Sklearn 实现 SVD

import numpy as np
A = np.array([[0,1],[1,1],[1,0]])
u, s, vt = np.linalg.svd(A, full_matrices=True)
print(u.shape, s.shape, vt.shape)

在这里插入图片描述
SVD 可以用于图片的压缩,只保留最重要信息,从 k=1 到 k=50:

import numpy as np
import os
from PIL import Image
from tqdm import tqdm# 定义恢复函数,由分解后的矩阵恢复到原矩阵
def restore(u, s, v, K): '''u:左奇异矩阵v:右奇异矩阵s:奇异值矩阵K:奇异值个数'''m, n = len(u), len(v[0])a = np.zeros((m, n))for k in range(K):uk = u[:, k].reshape(m, 1)vk = v[k].reshape(1, n)# 前k个奇异值的加总a += s[k] * np.dot(uk, vk)   a = a.clip(0, 255)return np.rint(a).astype('uint8')A = np.array(Image.open("./mountain.png", 'r'))
# 对RGB图像进行奇异值分解
u_r, s_r, v_r = np.linalg.svd(A[:, :, 0])    
u_g, s_g, v_g = np.linalg.svd(A[:, :, 1])
u_b, s_b, v_b = np.linalg.svd(A[:, :, 2])# 使用前50个奇异值
K = 50 
output_path = './svd_pic'
# 
for k in tqdm(range(1, K+1)):R = restore(u_r, s_r, v_r, k)G = restore(u_g, s_g, v_g, k)B = restore(u_b, s_b, v_b, k)I = np.stack((R, G, B), axis=2)   Image.fromarray(I).save('%s/svd_%d.jpg' % (output_path, k))

显示图片

from PIL import Image
from IPython.display import display, HTML
import os
import re
import time# Path to the folder containing images
image_folder = "./svd_pic"# List all image files
image_files = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]# Sort image files by the numeric part of the filename
def extract_number(filename):match = re.search(r'_(\d+)\.', filename)return int(match.group(1)) if match else float('inf')image_files = sorted(image_files, key=extract_number)# Generate HTML for horizontal display with cache busting
html = "<div style='display: flex; flex-direction: row; flex-wrap: wrap;'>"
timestamp = int(time.time())  # Use current timestamp for cache bustingfor idx, image_file in enumerate(image_files):img_path = os.path.join(image_folder, image_file)# Add a unique query parameter to disable cachingimg_url = f"{img_path}?v={timestamp}"img = Image.open(img_path)img_resized = img.resize((150, 150))  # Resize to 300x300img_resized.save("temp_resized.jpg")  # Save resized image temporarily# Add image with index number overlayhtml += f"""<div style="margin: 10px; position: relative; display: inline-block; text-align: center;"><img src="{img_url}" style="width: 150px; height: 150px; display: block;"><div style="position: absolute; top: 10px; left: 10px; background-color: rgba(0, 0, 0, 0.6); color: white; padding: 5px 10px; font-size: 16px; border-radius: 5px;">{idx + 1}</div></div>"""html += "</div>"# Display the images horizontally with no cache
display(HTML(html))

随着K 值增大,图片会越来越清晰。
在这里插入图片描述

总结

SVD 算法通过求解奇异值对矩阵进行分解,较大奇异值能表达更重要的信息。

http://www.hkea.cn/news/788306/

相关文章:

  • 营销型网站建设市场seo黑帽技术有哪些
  • 扬中做网站的公司seo虚拟外链
  • 永川集团网站建设免费网站seo诊断
  • 国外 上海网站建设网络营销推广方式案例
  • 24手表网站网络技术推广服务
  • 鞍山网站制作推广游戏推广员判几年
  • 360如何做网站优化网页设计制作软件
  • 金华网站建设电话电商运营主要负责什么
  • 百度的官方网站游戏推广工作好做吗
  • 著名的深圳网站建设网页快照
  • 政务网站建设要求快速排名软件哪个好
  • 自己网站怎么做优化色盲和色弱的区别
  • 苏州建网站公司seo网络推广培训班
  • 福清市建设局网站石家庄学院
  • 找考卷做要去哪个网站中国国家培训网官网查询
  • 软件系统开发的大概步骤优化网站标题名词解释
  • 院校网站建设模板建站平台
  • 淘宝网站内搜索引擎优化怎么做广告推广平台网站有哪些
  • 大片播放网站国外免费推广网站有哪些
  • flash网站cms排名sem优化软件
  • 申请完域名怎么做网站百度链接提交
  • 驻马店市可以做网站的公司百度搜索竞价排名
  • 郑州市做网站吉林百度查关键词排名
  • 济宁网站建设seo抖音seo源码搭建
  • 茂名网站建设方案书简述seo和sem的区别
  • 江西网站做的好的企业文化百度指数在哪里看
  • 山东电商网站建设seo网站排名优化公司
  • 赤峰市做网站公司今日的最新消息
  • 上海最大的贸易公司seo网络推广机构
  • jsp 网站开发广告发布平台