我是 TensorFlow 的新手,并尝试使用 Estimator API 进行一些简单的分类实验。我有一个libsvm 格式的稀疏数据集。以下输入函数适用于小型数据集:
def libsvm_input_function(file):
def input_function():
indexes_raw = []
indicators_raw = []
values_raw = []
labels_raw = []
i=0
for line in open(file, "r"):
data = line.split(" ")
label = int(data[0])
for fea in data[1:]:
id, value = fea.split(":")
indexes_raw.append([i,int(id)])
indicators_raw.append(int(1))
values_raw.append(float(value))
labels_raw.append(label)
i=i+1
indexes = tf.SparseTensor(indices=indexes_raw,
values=indicators_raw,
dense_shape=[i, num_features])
values = tf.SparseTensor(indices=indexes_raw,
values=values_raw,
dense_shape=[i, num_features])
labels = tf.constant(labels_raw, dtype=tf.int32)
return {"indexes": indexes, "values": values}, labels
return input_function
Run Code Online (Sandbox Code Playgroud)
但是,对于几 GB 大小的数据集,我收到以下错误:
ValueError:无法创建内容大于 2GB …
在Spring Boot中,我正在尝试创建一个RestTemplate,它将使用基本身份验证
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
builder.basicAuthorization("username", "password");
RestTemplate template = builder.build();
return template;
}
Run Code Online (Sandbox Code Playgroud)
然后我将RestTemplate注入我的服务类中
@Autowired
private RestTemplate restTemplate;
Run Code Online (Sandbox Code Playgroud)
但是,我的请求因401未经授权的例外而失败:
Caused by: org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
Run Code Online (Sandbox Code Playgroud)
使用另一个REST客户端(邮递员)对同一URL的请求成功,因此我假设基本身份验证无法正常工作.从调试输出看起来好像没有设置身份验证标头.什么使这项工作?