随笔分类 -  代码

摘要:容器中pytorch的cpu速度很慢,原因找到了 # import numpy as np # import time # import torch # import os # os.environ['OMP_NUM_THREADS'] = '8' # 增加线程数 # torch.set_num_t 阅读全文
posted @ 2025-11-05 16:57 bregman 阅读(26) 评论(0) 推荐(0)
摘要:def parse_parameters(param_string): """解析参数字符串,格式: k1:v1,k2:v2 注意:1e-4 -> 1.0e-4 """ if not param_string or ':' not in param_string: return {} return 阅读全文
posted @ 2025-08-31 08:10 bregman 阅读(19) 评论(0) 推荐(0)
摘要:参考 https://www.cnblogs.com/AndreaDO/p/17854742.html C/C++插件 code runner 插件 阅读全文
posted @ 2024-05-24 17:16 bregman 阅读(19) 评论(0) 推荐(0)
摘要:配置conda代理 $ cat ~/.condarc # https://help.mirrors.cernet.edu.cn/anaconda/ ubuntu@ubuntu-Z790-UD:/opt$ cat ~/.condarc channels: - defaults show_channel 阅读全文
posted @ 2024-05-03 15:38 bregman 阅读(72) 评论(2) 推荐(0)
摘要:#!/usr/bin/env python # -*- encoding:utf-8 -*- import tempfile import sys import os import subprocess import logging import re __all__ = ["run", "quer 阅读全文
posted @ 2024-03-12 10:37 bregman 阅读(17) 评论(0) 推荐(0)
摘要:用pytorch 2.2 快了不少 参考 https://pytorch.org/blog/compiling-numpy-code/ 在mac M2 机器上, 快了50%, 但没有好几倍。可能和依赖libomp有关 brew install libomp python test_np.py tes 阅读全文
posted @ 2023-10-23 19:23 bregman 阅读(163) 评论(0) 推荐(0)
摘要:* ortools 中提供了一个文档介绍快速具体算法 https://developers.google.cn/optimization/lp/lp_advanced?hl=en 其中实现了一个迭代法 PDLP, 对于低精度,以及给定初值的情况应该比较有利。 文档没有提供例子, 但代码路中有例子: 阅读全文
posted @ 2023-07-26 01:00 bregman 阅读(457) 评论(1) 推荐(0)
摘要:ps aux | grep test_streaming.py | sed -E 's/\s+/ /g; $d' | cut -d ' ' -f 2 | xargs -i kill -s 9 {} # linux ps ax | grep netron | sed -r 's/\s+/#/g;/gr 阅读全文
posted @ 2023-07-19 12:28 bregman 阅读(36) 评论(0) 推荐(0)
摘要:* 错误 ![image](https://img2023.cnblogs.com/blog/698752/202307/698752-20230701050756453-2131891592.png) * 解决方法: 通过和之前可以的任务对比,发现其中有Add dependencies with 阅读全文
posted @ 2023-07-01 05:11 bregman 阅读(676) 评论(0) 推荐(0)
摘要:```python import time import tensorflow as tf tf.compat.v1.disable_eager_execution() #%% 平均2.7秒。 发现conda 创建tf1.15 速度非常慢,应该环境配置有问题 A = tf.linalg.svd(tf 阅读全文
posted @ 2023-05-16 14:14 bregman 阅读(140) 评论(0) 推荐(0)
摘要:```python # %% import jax import jax.numpy as jnp import numpy as np def loss(params, r): lambda_a, lambda_s = params return jnp.maximum(r - lambda_a 阅读全文
posted @ 2023-05-13 13:26 bregman 阅读(56) 评论(0) 推荐(0)
摘要:好几年前写的代码, 其中javascript代码找专业人员写的。 ```python #######页面 _HTML = ''' 效果分析%(bizdate)s 算法效果报告 bizdate=%(bizdate)s %(tabs)s %(contents)s 注意数据安全, 请勿转发!! 有问题联系 阅读全文
posted @ 2022-11-23 11:31 bregman 阅读(49) 评论(0) 推荐(0)
摘要:0. 官方教材 https://pytorch.org/tutorials/beginner/basics/tensorqs_tutorial.html 1. https://huhuhang.com/post/machine-learning/pytorch-basic-tutorials 2. 阅读全文
posted @ 2022-11-13 18:45 bregman 阅读(53) 评论(1) 推荐(0)
摘要:* 用md5 ```python import hashlib _a = hashlib.md5(_model_file.encode('utf-8')).hexdigest() resource_name = f'tfmodel_{_a}.tar.gz' ``` * 不能缩短 ```python 阅读全文
posted @ 2022-08-20 00:13 bregman 阅读(70) 评论(0) 推荐(0)
摘要:之前的一段java代码, 发现耗时有点高, java 同事做了优化。方法如下: 1. 写一个测试类, profileTest分析代码中各部分的耗时。 2. 把java的split 的代码用for循环 去处理。 最终耗时从16ms下降到9ms。 想了下 java split 慢, 可能是正则表达式原因 阅读全文
posted @ 2022-07-19 11:41 bregman 阅读(83) 评论(0) 推荐(0)
摘要:* https://www.tutorialspoint.com/rust/rust_tutorial.pdf 150页 * https://lise-henry.github.io/books/trpl2.pdf 600页 * https://edu.anarcho-copy.org/Progra 阅读全文
posted @ 2022-07-14 20:22 bregman 阅读(44) 评论(0) 推荐(0)
摘要:* tf.switch_case, 1.15 以后版本生效 * fast_net 中不能用 lambda 函数, 否则结果不一致。 ```python def fast_net(branch_index, branch_names=branch_names): import functools br 阅读全文
posted @ 2022-07-10 10:33 bregman 阅读(79) 评论(0) 推荐(0)
摘要:``` s = settings;s.matlab.desktop.DisplayScaleFactor s.matlab.desktop.DisplayScaleFactor.PersonalValue = 1.2 ``` 阅读全文
posted @ 2022-04-23 08:56 bregman 阅读(99) 评论(0) 推荐(0)
摘要:参考 tf.metrics.mean, 编写一个广告中常用的pcoc 度量,在tf.esitmator 模型中使用 ```python class Kmetrics(object): @staticmethod def pcoc(labels, predictions, weights=None, 阅读全文
posted @ 2022-04-19 15:56 bregman 阅读(86) 评论(0) 推荐(0)
摘要:稀疏的string tensor 转dense, 每行一个值 ```python tf.sparse.to_dense(sp_x) ``` 或者 ```python def to_dense_mx1(sp): sp_x = tf.SparseTensor(indices=tf.concat((sp. 阅读全文
posted @ 2022-01-21 17:51 bregman 阅读(88) 评论(0) 推荐(0)