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

淘宝做导航网站有哪些不花钱的做网站

淘宝做导航网站有哪些,不花钱的做网站,平面设计接单渠道有哪些,ssh做的网站目录 一、什么是迁移学习 二、为什么需要迁移学习#xff1f; 1. 大数据与少标注的矛盾#xff1a; 2. 大数据与弱计算的矛盾#xff1a; 3. 普适化模型与个性化需求的矛盾#xff1a; 4. 特定应用#xff08;如冷启动#xff09;的需求。 三、迁移学习的基本问题有…目录 一、什么是迁移学习 二、为什么需要迁移学习 1. 大数据与少标注的矛盾 2. 大数据与弱计算的矛盾 3. 普适化模型与个性化需求的矛盾 4. 特定应用如冷启动的需求。 三、迁移学习的基本问题有哪些 四、 迁移学习有哪些常用概念 ​编辑 五、迁移学习与传统机器学习有什么区别 六、迁移学习的核心及度量准则  一、什么是迁移学习 迁移学习(Transfer Learning)是一种机器学习方法就是把为任务 A 开发 的模型作为初始点重新使用在为任务 B 开发模型的过程中。迁移学习是通过 从已学习的相关任务中转移知识来改进学习的新任务虽然大多数机器学习算 法都是为了解决单个任务而设计的但是促进迁移学习的算法的开发是机器学 习社区持续关注的话题。 迁移学习对人类来说很常见例如我们可能会发现 学习识别苹果可能有助于识别梨或者学习弹奏电子琴可能有助于学习钢琴。 找到目标问题的相似性迁移学习任务就是从相似性出发将旧领域 (domain)学习过的模型应用在新领域上 二、为什么需要迁移学习 1. 大数据与少标注的矛盾 虽然有大量的数据但往往都是没有标注的 无法训练机器学习模型。人工进行数据标定太耗时。 2. 大数据与弱计算的矛盾 普通人无法拥有庞大的数据量与计算资源。因 此需要借助于模型的迁移。 3. 普适化模型与个性化需求的矛盾 即使是在同一个任务上一个模型也 往往难以满足每个人的个性化需求比如特定的隐私设置。这就需要在 不同人之间做模型的适配。 4. 特定应用如冷启动的需求。 三、迁移学习的基本问题有哪些 基本问题主要有3个 How to transfer 如何进行迁移学习设计迁移方法What to transfer 给定一个目标领域如何找到相对应的源领域 然后进行迁移源领域选择When to transfer 什么时候可以进行迁移什么时候不可以避 免负迁移 四、 迁移学习有哪些常用概念 基本定义 域(Domain)数据特征和特征分布组成是学习的主体 源域 (Source domain)已有知识的域 目标域 (Target domain)要进行学习的域 任务 (Task)由目标函数和学习结果组成是学习的结果 按特征空间分类 按迁移情景分类 归纳式迁移学习Inductive TL源域和目标域的学习任务 不同 直推式迁移学习Transductive TL)源域和目标域不同学 习任务相同 无监督迁移学习Unsupervised TL)源域和目标域均没有 标签 按迁移方法分类 基于样本的迁移 (Instance based TL)通过权重重用源域和 目标域的样例进行迁移 基于样本的迁移学习方法 (Instance based Transfer Learning) 根据一定的权重生成规则对数据样本进行重用 来进行迁移学习。下图形象地表示了基于样本迁移方法的思想 源域中存在不同种类的动物如狗、鸟、猫等目标域只有狗 这一种类别。在迁移时为了最大限度地和目标域相似我们 可以人为地提高源域中属于狗这个类别的样本权重。 基于特征的迁移 (Feature based TL)将源域和目标域的特 征变换到相同空间   基于特征的迁移方法 (Feature based Transfer Learning) 是 指将通过特征变换的方式互相迁移,来减少源域和目标域之间的 差距或者将源域和目标域的数据特征变换到统一特征空间中, 然后利用传统的机器学习方法进行分类识别。根据特征的同构 和异构性,又可以分为同构和异构迁移学习。下图很形象地表示 了两种基于特 征的迁移学习方法。 基于模型的迁移 (Parameter based TL)利用源域和目标域的参数共享 模型 基于模型的迁移方法 (Parameter/Model based Transfer Learning) 是指 从源域和目标域中找到他们之间共享的参数信息,以实现迁移的方法。这种迁移 方式要求的假设条件是 源域中的数据与目标域中的数据可以共享一些模型的 参数。下图形象地表示了基于模型的迁移学习方法的基本思想。   基于关系的迁移 (Relation based TL)利用源域中的逻辑网络关系进行迁移 基于关系的迁移学习方法 (Relation Based Transfer Learning) 与上述三种 方法具有截然不同的思路。这种方法比较关注源域和目标域的样本之间的关 系。下图形象地表示了不 同领域之间相似的关系。   五、迁移学习与传统机器学习有什么区别 六、迁移学习的核心及度量准则  迁移学习的总体思路可以概括为开发算法来最大限度地利用有标注的领 域的知识来辅助目标领域的知识获取和学习。 迁移学习的核心是找到源领域和目标领域之间的相似性并加以合理利 用。这种相似性非常普遍。比如不同人的身体构造是相似的自行车和摩托 车的骑行方式是相似的国际象棋和中国象棋是相似的羽毛球和网球的打球 方式是相似的。这种相似性也可以理解为不变量。以不变应万变才能立于不 败之地。 有了这种相似性后下一步工作就是 如何度量和利用这种相似性。度量 工作的目标有两点一是很好地度量两个领域的相似性不仅定性地告诉我们 它们是否相似更定量地给出相似程度。二是以度量为准则通过我们所要采 用的学习手段增大两个领域之间的相似性从而完成迁移学习。 一句话总结 相似性是核心度量准则是重要手段。 七、迁移学习三步走 1加载预训练模型inceptionnet-v3主干网络backbone提取所 有图片数据集的特征特征向量2048维度。调用别人训练好的模型因为 他们的模型泛化能力强不用自己创建训练模型 2用特征向量训练自己的后端网络模型后端用自己创建dense后端模 型保存dense后端6个模型 3调用最后一个模型来显示测试集16张图片预测结果 第一步 import os.path import numpy as np # # import tensorflow.compat.v1 as tf # import tensorflow._api.v2.compat.v1 as tf import tensorflow.compat.v1 as tf tf.disable_v2_behavior() from tensorflow.python.platform import gfile MODEL_FILE model/tensorflow_inception_graph.pb JPEG_DATA_TENSOR_NAME DecodeJpeg/contents:0 BOTTLENECK_TENSOR_NAME pool_3/_reshape:0 INPUT_IMAGE data/agriculture OUTPUT_VEC data/bottleneck def load_google_model(path):with gfile.FastGFile(path, rb) as f:graph_def tf.GraphDef()graph_def.ParseFromString(f.read())jpeg_data_tensor, bottleneck_tensor \tf.import_graph_def(graph_def, return_elements [JPEG_DATA_TENSOR_NAME, BOTTLENECK_TENSOR_NAME])return jpeg_data_tensor, bottleneck_tensor def get_random_cached_bottlenecks(sess, path, jpeg_data_tensor, bottleneck_tensor):for _, class_name in enumerate(os.listdir(path)):sub_path os.path.join(path, class_name)for img in os.listdir(sub_path):img_pathos.path.join(sub_path,img)image_data gfile.FastGFile(img_path, rb).read()bottleneck_values sess.run(bottleneck_tensor, feed_dict{jpeg_data_tensor: image_data})第二步骤:bottleneck_values np.squeeze(bottleneck_values)sub_dir_path os.path.join(OUTPUT_VEC, class_name)if not os.path.exists(sub_dir_path):os.makedirs(sub_dir_path)new_image_pathos.path.join(sub_dir_path, img).txtif not os.path.exists(new_image_path):bottleneck_string ,.join(str(x) for x in bottleneck_values)with open(new_image_path, w) as bottleneck_file:bottleneck_file.write(bottleneck_string)else:break if __name__ __main__:jpeg_data_tensor, bottleneck_tensor load_google_model(MODEL_FILE)with tf.Session() as sess:tf.global_variables_initializer().run()get_random_cached_bottlenecks(sess, INPUT_IMAGE, jpeg_data_tensor, bottleneck_tensor) 第二步  import os import numpy as np import tensorflow.compat.v1 as tf tf.disable_v2_behavior() # import tensorflow._api.v2.compat.v1 as tf from sklearn.model_selection import train_test_split IN_DIR data/bottleneck OUT_DIR runs checkpoint_every 100 #every 每, def get_data(path):   x_vecs[]y_labels[]for i, j in enumerate(os.listdir(path)): #enumerate代表枚 举把元素一个个列举出来。sub_path os.path.join(path, j)for vec in os.listdir(sub_path):vec_path os.path.join(sub_path, vec)with open(vec_path, r) as f:vec_str f.read()vec_values [float(x) for x in vec_str.split(,)]x_vecs.append(vec_values)y_labels.append(np.eye(5)[i])return np.array(x_vecs), np.array(y_labels) image_data,labelsget_data(IN_DIR) train_data,test_data,train_label,test_labeltrain_test_split( image_data,labels,train_size0.8,shuffleTrue) test_data,val_data,test_label,val_labeltrain_test_split(test _data,test_label,train_size0.5) if __name__ __main__:#入口X tf.placeholder(tf.float32, [None, 2048])Y tf.placeholder(tf.float32, [None, 5])with tf.name_scope(final_training_ops):logits tf.layers.dense(X, 5)with tf.name_scope(loss):cross_entropy_mean tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits logits, labelsY))with tf.name_scope(Optimizer):train_step tf.train.GradientDescentOptimizer(0.001).minimize(cross_entro py_mean)with tf.name_scope(evaluation):       correct_prediction tf.equal(tf.argmax(logits, 1), tf.argmax(Y, 1))evaluation_step tf.reduce_mean(tf.cast(correct_prediction, tf.float32))with tf.Session() as sess:sess.run(tf.global_variables_initializer())# 保存检查点checkpoint_dir os.path.abspath(os.path.join(OUT_DIR, checkpoints))checkpoint_prefix os.path.join(checkpoint_dir, model)if not os.path.exists(checkpoint_dir):os.makedirs(checkpoint_dir)saver tf.train.Saver(tf.global_variables(), max_to_keep6)for epoch in range(1001):batch_size 64start 0num_step len(train_data) // batch_sizefor i in range(num_step):xb train_data[start : start batch_size]yb train_label[start : start batch_size]start start batch_size_ sess.run([train_step], feed_dict{X: xb, Y: yb})if epoch % 100 0:validation_accuracy sess.run(evaluation_step, feed_dict{X: val_data, Y: val_label})print([epoch {}]验证集准确率 {:.3f}%.format(epoch, validation_accuracy * 100))path saver.save(sess, checkpoint_prefix, global_stepepoch)print(Saved model checkpoint to {}\n.format(path))test_accuracy sess.run(evaluation_step, feed_dict {X: test_data, Y: test_label})第三步骤:print(测试集准确率{:.3f}%.format(test_accuracy * 100)) 第三步 import numpy as np import cv2 import os import tensorflow.compat.v1 as tf tf.disable_v2_behavior() from tensorflow.python.platform import gfile import matplotlib.pyplot as plt MODEL_FILE model/tensorflow_inception_graph.pb JPEG_DATA_TENSOR_NAME DecodeJpeg/contents:0 BOTTLENECK_TENSOR_NAME pool_3/_reshape:0 CHECKPOINT_DIR runs/checkpoints test_dir data/test/agriculture def load_google_model(path):with gfile.FastGFile(path, rb) as f:graph_def tf.GraphDef()graph_def.ParseFromString(f.read())jpeg_data_tensor, bottleneck_tensor \tf.import_graph_def(graph_def, return_elements [JPEG_DATA_TENSOR_NAME, BOTTLENECK_TENSOR_NAME])return jpeg_data_tensor, bottleneck_tensor def create_test_featrue(sess, test_dir, jpeg_data_tensor, bottleneck_tensor):test_data, test_feature, test_labels [], [], []for i in os.listdir(test_dir):img cv2.imread(os.path.join(test_dir, i))img cv2.resize(img, (256, 256))img cv2.cvtColor(img, cv2.COLOR_RGB2BGR)test_data.append(img)img_data gfile.FastGFile(os.path.join(test_dir, i), rb).read()       feature sess.run(bottleneck_tensor, feed_dict {jpeg_data_tensor: img_data})test_feature.append(feature)test_labels.append(i.split(_)[0])return test_data, np.reshape(test_feature, (-1, 2048)), np.array(test_labels) def show_img(test_data, pre_labels, test_labels):_, axs plt.subplots(4, 4)for i, axi in enumerate(axs.flat):axi.imshow(test_data[i])print(pre_labels[i], test_labels[i])axi.set_xlabel(xlabelpre_labels[i], colorblack if pre_labels[i] test_labels[i] else red)axi.set(xticks[], yticks[])plt.savefig(os.path.join(data/test/, agriculture .jpg))plt.show() if __name__ __main__:jpeg_data_tensor, bottleneck_tensor load_google_model(MODEL_FILE)class_names os.listdir(data/agriculture)num_class len(class_names)x_transfer tf.placeholder(tf.float32, [None, 2048])y_transfer tf.placeholder(tf.int64, [None, num_class]) # [None,5]logits tf.layers.dense(x_transfer, num_class)saver tf.train.Saver()with tf.Session() as sess:sess.run(tf.global_variables_initializer())print(CHECKPOINT_DIR)last_point tf.train.latest_checkpoint(CHECKPOINT_DIR)print(last_point)saver.restore(sess, last_point)三个步骤代码组合起来实现迁移学习:test_data, test_feature, test_labels \create_test_featrue(sess, test_dir, jpeg_data_tensor, bottleneck_tensor)pred sess.run(tf.argmax(logits, 1), {x_transfer: test_feature})show_img(test_data, [class_names[i] for i in pred], test_labels)
文章转载自:
http://www.morning.0small.cn.gov.cn.0small.cn
http://www.morning.lzwfg.cn.gov.cn.lzwfg.cn
http://www.morning.rbnj.cn.gov.cn.rbnj.cn
http://www.morning.sffwz.cn.gov.cn.sffwz.cn
http://www.morning.mqzcn.cn.gov.cn.mqzcn.cn
http://www.morning.npxcc.cn.gov.cn.npxcc.cn
http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com
http://www.morning.ltqtp.cn.gov.cn.ltqtp.cn
http://www.morning.msgcj.cn.gov.cn.msgcj.cn
http://www.morning.fkrzx.cn.gov.cn.fkrzx.cn
http://www.morning.srrrz.cn.gov.cn.srrrz.cn
http://www.morning.xgkxy.cn.gov.cn.xgkxy.cn
http://www.morning.trsmb.cn.gov.cn.trsmb.cn
http://www.morning.juju8.cn.gov.cn.juju8.cn
http://www.morning.rqlbp.cn.gov.cn.rqlbp.cn
http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn
http://www.morning.nlnmy.cn.gov.cn.nlnmy.cn
http://www.morning.syhwc.cn.gov.cn.syhwc.cn
http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn
http://www.morning.mmhaoma.com.gov.cn.mmhaoma.com
http://www.morning.ddxjr.cn.gov.cn.ddxjr.cn
http://www.morning.gtkyr.cn.gov.cn.gtkyr.cn
http://www.morning.ccphj.cn.gov.cn.ccphj.cn
http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn
http://www.morning.stlgg.cn.gov.cn.stlgg.cn
http://www.morning.ylph.cn.gov.cn.ylph.cn
http://www.morning.rqxmz.cn.gov.cn.rqxmz.cn
http://www.morning.ktqtf.cn.gov.cn.ktqtf.cn
http://www.morning.ryzgp.cn.gov.cn.ryzgp.cn
http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn
http://www.morning.wjhpg.cn.gov.cn.wjhpg.cn
http://www.morning.lbggk.cn.gov.cn.lbggk.cn
http://www.morning.qlckc.cn.gov.cn.qlckc.cn
http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn
http://www.morning.llqch.cn.gov.cn.llqch.cn
http://www.morning.trffl.cn.gov.cn.trffl.cn
http://www.morning.fhrgk.cn.gov.cn.fhrgk.cn
http://www.morning.myzfz.com.gov.cn.myzfz.com
http://www.morning.pnmnl.cn.gov.cn.pnmnl.cn
http://www.morning.svrud.cn.gov.cn.svrud.cn
http://www.morning.lxqyf.cn.gov.cn.lxqyf.cn
http://www.morning.jcffp.cn.gov.cn.jcffp.cn
http://www.morning.bfwk.cn.gov.cn.bfwk.cn
http://www.morning.bmncq.cn.gov.cn.bmncq.cn
http://www.morning.qmnjn.cn.gov.cn.qmnjn.cn
http://www.morning.yjfzk.cn.gov.cn.yjfzk.cn
http://www.morning.dnmgr.cn.gov.cn.dnmgr.cn
http://www.morning.pwghp.cn.gov.cn.pwghp.cn
http://www.morning.yrmpr.cn.gov.cn.yrmpr.cn
http://www.morning.jcjgh.cn.gov.cn.jcjgh.cn
http://www.morning.qzqjz.cn.gov.cn.qzqjz.cn
http://www.morning.ycwym.cn.gov.cn.ycwym.cn
http://www.morning.gypcr.cn.gov.cn.gypcr.cn
http://www.morning.zdmrf.cn.gov.cn.zdmrf.cn
http://www.morning.wbdm.cn.gov.cn.wbdm.cn
http://www.morning.tmcmj.cn.gov.cn.tmcmj.cn
http://www.morning.nwqyq.cn.gov.cn.nwqyq.cn
http://www.morning.xhddb.cn.gov.cn.xhddb.cn
http://www.morning.burpgr.cn.gov.cn.burpgr.cn
http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn
http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn
http://www.morning.kztpn.cn.gov.cn.kztpn.cn
http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn
http://www.morning.jmllh.cn.gov.cn.jmllh.cn
http://www.morning.dpjtn.cn.gov.cn.dpjtn.cn
http://www.morning.zlkps.cn.gov.cn.zlkps.cn
http://www.morning.ftmzy.cn.gov.cn.ftmzy.cn
http://www.morning.zkzjm.cn.gov.cn.zkzjm.cn
http://www.morning.jhqcr.cn.gov.cn.jhqcr.cn
http://www.morning.xjkr.cn.gov.cn.xjkr.cn
http://www.morning.mjtgt.cn.gov.cn.mjtgt.cn
http://www.morning.qgwdc.cn.gov.cn.qgwdc.cn
http://www.morning.pxlql.cn.gov.cn.pxlql.cn
http://www.morning.sbyhj.cn.gov.cn.sbyhj.cn
http://www.morning.wqpm.cn.gov.cn.wqpm.cn
http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn
http://www.morning.mkydt.cn.gov.cn.mkydt.cn
http://www.morning.hympq.cn.gov.cn.hympq.cn
http://www.morning.pswzc.cn.gov.cn.pswzc.cn
http://www.morning.tblbr.cn.gov.cn.tblbr.cn
http://www.tj-hxxt.cn/news/278581.html

相关文章:

  • 网站建设市场行情分析做网站设分辨率
  • 专业网站制作的费用seo优化费用
  • 如何创建网站快捷方式到桌面那家网站建设公司好
  • 有没有做专利导航运营的网站有哪些程序做的网站
  • 虫部落是谁做的网站作文网课哪家好
  • 上海先进网站设计潜江seo
  • 做网站多久能盈利中山做公司网站
  • 有哪些档案网站好玩的微信小程序游戏排行榜前十名
  • 网站平台建设项目检查汇报材料医药招商网站建设
  • 个人买卖网站怎么做网站做不做双解析
  • 酒店网站策划书广告东莞网站建设技术支持
  • 建站公司属于什么类型保定网站排名哪家公司好
  • 睢宁建网站用织梦后台修改网站logo
  • 怎么编写网站代码外国网站开发
  • 公司集团网站设计做外贸soho网站的公司吗
  • 招网站开发人员山东泰安网络推广
  • 微网站制作多少钱西安小程序
  • 网站建设宣传文案盘锦市政建设集团网站
  • 类做秋霞的网站项目管理证书
  • 电子商务网站建设合同范本电子商务网站的建设开发工具
  • 网站开发的现状及研究意义wordpress 文章转页面
  • 公司网页网站建设 ppt模板下载wordpress主题中文字体插件
  • 网站备案密码客户说做网站价格高
  • 做静态网站徐州列表网
  • 南宁定制网站建设桂林漓江旅游
  • 专业的内蒙古网站建设长沙做php的网站建设
  • dw网站大学生代做抖音代运营协议合同范本免费下载
  • 点击网站首页域名又添加一个wordpress 标签seo插件
  • 网站外部链接怎么做建设一个直播网站多少钱
  • 养殖推广网站怎么做灵台县门户网