mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 06:15:56 +03:00
load text
This commit is contained in:
parent
d6b9ba849f
commit
75d81a0c15
@ -56,11 +56,11 @@
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="com.nvidia.cuda.ide.seven_five.configuration.debug.1479727693.1233477758" name="tensor.cu" rcbsApplicability="disable" resourcePath="tensor.cu" toolsToInvoke="nvcc.compiler.base.1979453423.1456105605">
|
||||
<tool id="nvcc.compiler.base.1979453423.1456105605" name="NVCC Compiler" superClass="nvcc.compiler.base.1979453423"/>
|
||||
<fileInfo id="com.nvidia.cuda.ide.seven_five.configuration.debug.1479727693.1770712140" name="tensor.cu" rcbsApplicability="disable" resourcePath="tensor.cu" toolsToInvoke="nvcc.compiler.base.1979453423.1452902875">
|
||||
<tool id="nvcc.compiler.base.1979453423.1452902875" name="NVCC Compiler" superClass="nvcc.compiler.base.1979453423"/>
|
||||
</fileInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="tensor.cu" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -10,6 +10,7 @@ cuda_add_executable(
|
||||
test.cu
|
||||
expressions.cu
|
||||
tensor_operators.cu
|
||||
tensor.cu
|
||||
$<TARGET_OBJECTS:libcommon>
|
||||
)
|
||||
|
||||
|
23
src/tensor.cu
Normal file
23
src/tensor.cu
Normal file
@ -0,0 +1,23 @@
|
||||
#include <fstream>
|
||||
#include "tensor.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace marian {
|
||||
|
||||
void Tensor::Load(const std::string &path)
|
||||
{
|
||||
fstream strm;
|
||||
strm.open(path.c_str());
|
||||
|
||||
string line;
|
||||
while ( getline (strm, line) )
|
||||
{
|
||||
cerr << line << '\n';
|
||||
}
|
||||
strm.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -240,6 +240,8 @@ class Tensor {
|
||||
return pimpl_->Debug();
|
||||
}
|
||||
|
||||
void Load(const std::string &path);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
35
src/test.cu
35
src/test.cu
@ -8,6 +8,7 @@ int main(int argc, char** argv) {
|
||||
using namespace marian;
|
||||
using namespace keywords;
|
||||
|
||||
/*
|
||||
Expr x = input(shape={whatevs, 784}, name="X");
|
||||
Expr y = input(shape={whatevs, 10}, name="Y");
|
||||
|
||||
@ -30,10 +31,29 @@ int main(int argc, char** argv) {
|
||||
y = ty;
|
||||
|
||||
graph.forward(500);
|
||||
graph.backward();
|
||||
//std::cerr << graph["pred"].val()[0] << std::endl;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
Expr x = input(shape={whatevs, 2}, name="X");
|
||||
Expr y = input(shape={whatevs, 2}, name="Y");
|
||||
|
||||
Expr w = param(shape={2, 1}, name="W0");
|
||||
Expr b = param(shape={1, 1}, name="b0");
|
||||
|
||||
Expr n5 = dot(x, w);
|
||||
Expr n6 = n5 + b;
|
||||
Expr lr = softmax(n6, axis=1, name="pred");
|
||||
cerr << "lr=" << lr.Debug() << endl;
|
||||
|
||||
Expr graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost");
|
||||
|
||||
Tensor tx({4, 2}, 1);
|
||||
Tensor ty({4, 1}, 1);
|
||||
tx.Load("/Users/hieu/workspace/experiment/issues/marian/1st/train.txt");
|
||||
ty.Load("/Users/hieu/workspace/experiment/issues/marian/1st/label.txt");
|
||||
|
||||
|
||||
//hook0(graph);
|
||||
//graph.autodiff();
|
||||
//std::cerr << graph["cost"].val()[0] << std::endl;
|
||||
@ -54,16 +74,5 @@ int main(int argc, char** argv) {
|
||||
// verbose=1, epochs=3, early_stopping=10);
|
||||
//opt.run();
|
||||
|
||||
Expr x2 = input(shape={whatevs, 2}, name="X2");
|
||||
Expr y2 = input(shape={whatevs, 2}, name="Y2");
|
||||
|
||||
Expr w2 = param(shape={2, 1}, name="W02");
|
||||
Expr b2 = param(shape={1, 1}, name="b02");
|
||||
|
||||
Expr n52 = dot(x2, w2);
|
||||
Expr n62 = n52 + b2;
|
||||
Expr lr2 = softmax(n62, axis=1, name="pred2");
|
||||
cerr << "lr=" << lr2.Debug() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user