我想知道如何使用TensorFlow处理图像分割中未标记的图像部分.例如,我的输入是高度*宽度*通道的图像.标签尺寸高度*宽度太大,每个像素都有一个标签.
图像的某些部分是注释的,其他部分则没有.我希望这些部分对梯度计算没有任何影响.此外,我对网络预测这个"无效"标签不感兴趣.
这有标签或功能吗?目前我正在使用tf.nn.sparse_softmax_cross_entropy_with_logits
.
python neural-network image-segmentation deep-learning tensorflow
我正在尝试使用TensorFlow构建一个简单的神经网络.目标是在32像素x 32像素图像中找到矩形的中心.矩形由五个向量描述.第一个矢量是位置矢量,另外四个是方向矢量,构成矩形边.一个向量具有两个值(x和y).
该图像的相应输入将是(2,5)(0,4)(6,0)(0,-4)( - 6,0).中心(因此所需的输出)位于(5,7).
我想出的代码如下所示:
import tensorflow as tf import numpy as np import Rectangle_Records def init_weights(shape): """ Weight initialization """ weights = tf.random_normal(shape, stddev=0.1) return tf.Variable(weights) def forwardprop(x, w_1, w_2): """ Forward-propagation """ h = tf.nn.sigmoid(tf.matmul(x, w_1)) y_predict = tf.matmul(h, w_2) return y_predict def main(): x_size = 10 y_size = 2 h_1_size = 256 # Prepare input data input_data = Rectangle_Records.DataSet() x = tf.placeholder(tf.float32, shape = [None, x_size]) y_label = tf.placeholder(tf.float32, shape = [None, …
我想知道ListView中的视图是否存在某种OnVisibilyChangeListener,因为我希望每次ListView项目更改其可见性时都会调用一个方法.
我知道OnPreDrawListener来检查视图是否可见.但是,我如何检查视图是否滚动到可见屏幕区域之外?
由于我的旧版.net,我使用的是旧版本的nHibernate.QueryOver不是一个选项.使用nhibernate计算表行的有效方法是什么?
我试图让nanohttpd在android下工作.我用过这个例子:
package com.example.android_test;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import com.example.android_test.NanoHTTPD.Response.Status;
import android.app.Activity;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final int PORT = 8765;
private TextView hello;
private MyHTTPD server;
private Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hello = (TextView) findViewById(R.id.hello);
}
@Override
protected void onResume() {
super.onResume();
TextView textIpaddr = (TextView) findViewById(R.id.ipaddr);
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
int ipAddress = …
Run Code Online (Sandbox Code Playgroud) 我试图使用preprocessing
from 将某个数字缩放到0到1的范围sklearn
.多数民众赞成我所做的:
data = [44.645, 44.055, 44.54, 44.04, 43.975, 43.49, 42.04, 42.6, 42.46, 41.405]
min_max_scaler = preprocessing.MinMaxScaler(feature_range=(0, 1))
data_scaled = min_max_scaler.fit_transform([data])
print data_scaled
Run Code Online (Sandbox Code Playgroud)
但data_scaled只包含零.我究竟做错了什么?
是否有可能找出函数的返回类型和参数类型并将它们用作模板类型?请考虑以下示例:
template <typename ret, typename in>
class Bar {
// Some code
}
int foo(float x) {
return 0;
}
int main() {
Bar<int, float> b; // Can this be done automatically by inspection of foo at compile time?
}
Run Code Online (Sandbox Code Playgroud)
我可以使用foo的函数签名来设置Bar的模板类型吗?
请考虑以下代码示例:
#include <functional>
#include <iostream>
template <typename... Ts>
class SomeClass
{
public:
std::function<bool(Ts...)> some_func;
void run(Ts... args)
{
this->some_func(args...); // this works
this->thread_run((void *)&this->some_func, args); // this won't work, can't pass the parameter pack
}
static void thread_run(void *func_ptr, void *args_ptr)
{
auto thread_func = *(std::function<bool(Ts...)> *)(func_ptr);
thread_func(2, 3);
}
};
int main()
{
SomeClass<int, int> a;
a.some_func = [](int x, int y)
{ std::cout << "Arguments: " << x << " " << y << std::endl; return x > …
Run Code Online (Sandbox Code Playgroud) 我想在某个类的成员变量中保留一个线程。以下代码段显示了我想要实现的目标:
#include <iostream>
#include <thread>
#include <vector>
class Test {
public:
std::thread& t;
Test(std::thread&& rt) : t(rt) {}
};
int main()
{
std::vector<Test> tests;
{
std::thread t ([]{
std::cout << 1;
});
tests.push_back(Test(std::move(t)));
}
for(Test mytest : tests)
{
mytest.t.join();
}
}
Run Code Online (Sandbox Code Playgroud)
该代码将在join()行处中断。错误是:
terminate called without an active exception
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
保留原始线程创建的范围后,为什么不能通过mytest.t调用线程?
c++ ×3
python ×3
android ×2
tensorflow ×2
c++11 ×1
hql ×1
listview ×1
nanohttpd ×1
nhibernate ×1
scikit-learn ×1
std-function ×1
stdthread ×1
templates ×1