Android 应用开发培训 PDF 指南

需积分: 10 5 下载量 4 浏览量 更新于2024-07-22 收藏 13MB PDF 举报
Android Developer Training PDF 格式文档概述 Android Developer Training PDF 格式文档是 Google 官方提供的 Android 开发者培训文档的 PDF 格式版本,该文档将官方网站上的内容编辑成了一个便于查看的 PDF 文档。 Android 开发者培训文档的主要内容包括 Android 应用程序开发的基础知识、Android 应用程序开发的进阶知识、Android 应用程序开发的高级知识等。该文档涵盖了 Android 应用程序开发的各个方面,包括 Android 基础知识、用户界面设计、数据存储、网络编程、多媒体处理、安全性等。 Android 开发者培训文档的优点包括: * 官方认证:该文档是 Google 官方提供的,确保了文档的权威性和准确性。 * 全面性:该文档涵盖了 Android 应用程序开发的各个方面,无论是基础知识还是高级知识。 * 易读性:该文档的内容清晰易懂,适合不同水平的开发者。 * 实践性:该文档提供了许多实践项目和代码示例,帮助开发者快速掌握 Android 应用程序开发的技能。 Android 开发者培训文档的结构包括: * 基础知识:介绍 Android 应用程序开发的基础知识,包括 Android 基础知识、用户界面设计、数据存储等。 * 进阶知识:介绍 Android 应用程序开发的进阶知识,包括网络编程、多媒体处理、安全性等。 * 高级知识:介绍 Android 应用程序开发的高级知识,包括 Android sistema 架构、Android NDK 等。 Android 开发者培训文档的license 信息包括: * Creative Commons 2.5 Attribution License:该License 适用于 Android Open Source Project 的一些部分。 * Apache 2.0 License:该License 适用于代码示例。 * Creative Commons Attribution-NonCommercial 3.0 Unported License:该License 适用于该文档的其他部分。 Android Developer Training PDF 格式文档是 Android 应用程序开发者的必备资源,该文档提供了全面、实践的 Android 应用程序开发知识,帮助开发者快速掌握 Android 应用程序开发的技能。

import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ["SimHei"] # 单使用会使负号显示错误 plt.rcParams['axes.unicode_minus'] = False # 把负号正常显示 # 读取北京房价数据 path = 'data.txt' data = pd.read_csv(path, header=None, names=['房子面积', '房子价格']) print(data.head(10)) print(data.describe()) # 绘制散点图 data.plot(kind='scatter', x='房子面积', y='房子价格') plt.show() def computeCost(X, y, theta): inner = np.power(((X * theta.T) - y), 2) return np.sum(inner) / (2 * len(X)) data.insert(0, 'Ones', 1) cols = data.shape[1] X = data.iloc[:,0:cols-1]#X是所有行,去掉最后一列 y = data.iloc[:,cols-1:cols]#X是所有行,最后一列 print(X.head()) print(y.head()) X = np.matrix(X.values) y = np.matrix(y.values) theta = np.matrix(np.array([0,0])) print(theta) print(X.shape, theta.shape, y.shape) def gradientDescent(X, y, theta, alpha, iters): temp = np.matrix(np.zeros(theta.shape)) parameters = int(theta.ravel().shape[1]) cost = np.zeros(iters) for i in range(iters): error = (X * theta.T) - y for j in range(parameters): term = np.multiply(error, X[:, j]) temp[0, j] = theta[0, j] - ((alpha / len(X)) * np.sum(term)) theta = temp cost[i] = computeCost(X, y, theta) return theta, cost alpha = 0.01 iters = 1000 g, cost = gradientDescent(X, y, theta, alpha, iters) print(g) print(computeCost(X, y, g)) x = np.linspace(data.Population.min(), data.Population.max(), 100) f = g[0, 0] + (g[0, 1] * x) fig, ax = plt.subplots(figsize=(12,8)) ax.plot(x, f, 'r', label='Prediction') ax.scatter(data.Population, data.Profit, label='Traning Data') ax.legend(loc=2) ax.set_xlabel('房子面积') ax.set_ylabel('房子价格') ax.set_title('北京房价拟合曲线图') plt.show()

2023-06-04 上传
2023-06-01 上传
2023-06-01 上传

import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt from torch import autograd """ 用神经网络模拟微分方程,f(x)'=f(x),初始条件f(0) = 1 """ class Net(nn.Module): def __init__(self, NL, NN): # NL n个l(线性,全连接)隐藏层, NN 输入数据的维数, # NL是有多少层隐藏层 # NN是每层的神经元数量 super(Net, self).__init__() self.input_layer = nn.Linear(1, NN) self.hidden_layer = nn.Linear(NN,int(NN/2)) ## 原文这里用NN,我这里用的下采样,经过实验验证,“等采样”更优。更多情况有待我实验验证。 self.output_layer = nn.Linear(int(NN/2), 1) def forward(self, x): out = torch.tanh(self.input_layer(x)) out = torch.tanh(self.hidden_layer(out)) out_final = self.output_layer(out) return out_final net=Net(4,20) # 4层 20个 mse_cost_function = torch.nn.MSELoss(reduction='mean') # Mean squared error 均方误差求 optimizer = torch.optim.Adam(net.parameters(),lr=1e-4) # 优化器 def ode_01(x,net): y=net(x) y_x = autograd.grad(y, x,grad_outputs=torch.ones_like(net(x)),create_graph=True)[0] return y-y_x # y-y' = 0 # requires_grad=True).unsqueeze(-1) plt.ion() # 动态图 iterations=200000 for epoch in range(iterations): optimizer.zero_grad() # 梯度归0 ## 求边界条件的损失函数 x_0 = torch.zeros(2000, 1) y_0 = net(x_0) mse_i = mse_cost_function(y_0, torch.ones(2000, 1)) # f(0) - 1 = 0 ## 方程的损失函数 x_in = np.random.uniform(low=0.0, high=2.0, size=(2000, 1)) pt_x_in = autograd.Variable(torch.from_numpy(x_in).float(), requires_grad=True) # x 随机数 pt_y_colection=ode_01(pt_x_in,net) pt_all_zeros= autograd.Variable(torch.from_numpy(np.zeros((2000,1))).float(), requires_grad=False) mse_f=mse_cost_function(pt_y_colection, pt_all_zeros) # y-y' = 0 loss = mse_i + mse_f loss.backward() # 反向传播 optimizer.step() # 优化下一步。This is equivalent to : theta_new = theta_old - alpha * derivative of J w.r.t theta if epoch%1000==0: y = torch.exp(pt_x_in) # y 真实值 y_train0 = net(pt_x_in) # y 预测值 print(epoch, "Traning Loss:", loss.data) print(f'times {epoch} - loss: {loss.item()} - y_0: {y_0}') plt.cla() plt.scatter(pt_x_in.detach().numpy(), y.detach().numpy()) plt.scatter(pt_x_in.detach().numpy(), y_train0.detach().numpy(),c='red') plt.pause(0.1)

2023-02-15 上传