public static void DoubleWithDemo() { using (TfScope scope = Tf.NameScope("scopeName"), scope2 = Tf.NameScope("scopeName")) { Py.Nothing(); } }
///<summary>обект үүсгээд хүүхдийг аваад устгана</summary> public static T DstGoChild <T>(GameObject goPf, Tf tf, float time, string childs = "", string name = "", Transform parTf = null) { GameObject go = Go <GameObject>(goPf, tf, name, parTf); MonoBehaviour.Destroy(go, time); return(go.Child <T>(childs)); }
public static Tensor <double> Loss(Tensor <double> logits, Tensor <int> labels) { var labels2 = Tf.ToInt64(labels); var crossEntropy = Tf.Nn.SparseSoftmaxCrossEntropyWithLogits(logits: logits, labels: labels2, name: "xentropy"); var loss = Tf.ReduceMean(crossEntropy, name: "xentropy_mean"); return(loss); }
///<summary>обект үүсгэнэ</summary> public static T Go <T>(GameObject goPf, Tf tf, string name = "", Transform parTf = null) { GameObject go = MonoBehaviour.Instantiate(goPf, tf.t, tf.q, parTf); go.transform.localScale = tf.s; if (!name.IsNullOrEmpty()) { go.name = name; } return(go.Gc <T>()); }
public void UpdateLetterDisplay() { GameObject text = Tf.GetChild(0).GetChild(0).gameObject; TextMesh tm = text.GetComponent(typeof(TextMesh)) as TextMesh; if (tm != null) { tm.text = this.ASCIIString; } }
// mesh-г tf-р хувиргана public static void UpdTf(ref Mesh mesh, Tf tf) { Vector3[] vs = mesh.vertices.Cln(); Vector3[] ns = mesh.normals.Cln(); for (int i = 0; i < vs.Length; i++) { vs[i] = Tf.Rot(tf.r, V3.Mul(vs[i], tf.s)) + tf.t; ns[i] = Tf.Rot(tf.r, ns[i]).normalized; } mesh.vertices = vs; mesh.normals = ns; }
public void GivenBagOfWordsTfIsCorrect() { var bagOfWords = new BagOfWords(new Document(new[] { "fly", "fly", "fly", "fruit", })); var tf = new Tf(bagOfWords); Assert.AreEqual(0.33333333, tf.TermWeight("fruit"), 0.00001); Assert.AreEqual(1d, tf.TermWeight("fly"), 0.00001); Assert.That(tf.TermWeight("nonexisting"), Is.EqualTo(0)); }
///<summary>PrimitiveType-тай обект үүсгэнэ</summary> public static GameObject Pri(PrimitiveType type, Tf tf, Color col = default(Color), string name = "", Transform parTf = null) { GameObject go = GameObject.CreatePrimitive(type); go.transform.position = tf.t; go.transform.rotation = tf.q; go.transform.localScale = tf.s; go.Gc <Renderer>().material.color = col.IsDefault() ? Color.white : col; if (!name.IsNullOrEmpty()) { go.name = name; } go.transform.parent = parTf; return(go); }
private void BurnTile() { Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = BurningMat; Transform ll = boardScript.NewLavaLight(); ll.SetParent(Tf.GetChild(0), false); ll.name = "Point light"; // Need a point light //Tf.GetChild(0).gameObject.SetActive(true); //GameObject t = (GameObject)Instantiate(LavaLight, new Vector3(0, 0, 0), Quaternion.identity); //t.transform.SetParent(Tf); // Object.Instantiate(); //Tf.GetChild(0).gameObject.SetActive(true); LetterAnimator.SetTrigger(Burning); }
public static void inferenceb(Tensor <double> images, int hidden1Units) { // ReSharper disable once LocalVariableHidesMember const int NUM_CLASSES = 10; // ReSharper disable once LocalVariableHidesMember const int IMAGE_SIZE = 28; using (var scope = Tf.NameScope("scopeName")) { var weights = Tf.Variable( Tf.TruncatedNormal(new[] { IMAGE_PIXELS, hidden1Units }, stddev: 1.0 / Math.Sqrt(IMAGE_PIXELS)), name: "weights"); var biases = Tf.Variable(Tf.ZerosDouble(new[] { hidden1Units }), name: "biases"); var hidden1 = Tf.Nn.Relu(Tf.MatMul(images, weights) + biases); } }
public void UpdateMaterial() { switch (tt) { case TileTypes.Burning: BurnTile(); break; case TileTypes.Normal: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = NoramlMat; break; case TileTypes.WordDouble: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = WordDoubleMat; break; case TileTypes.WordTriple: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = WordTripleMat; break; case TileTypes.LetterDouble: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = LetterDoubleMat; break; case TileTypes.LetterTriple: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = LetterTripleMat; break; case TileTypes.Manna: Tf.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = ManaMat; break; default: Tf.gameObject.GetComponent <MeshRenderer>().material = NoramlMat; break; } }
///<summary>обект үүсгээд хүүхдийг авна</summary> public static T GoChild <T>(GameObject goPf, Tf tf, string childs = "", string name = "", Transform parTf = null) { GameObject go = Go <GameObject>(goPf, tf, name, parTf); return(go.Child <T>(childs)); }
///<summary>tf-г pnt цэг дээр төвтэй axis тэнхлэгийн дагуу ang өнцгөөр эргүүлхэд гарах байрлалыг буцаана</summary> public static Vector3 RotAround(Tf tf, Vector3 pnt, Vector3 axis, float ang) { return(pnt + Q.AngAxis(ang, axis) * (tf.t - pnt)); }
///<summary>pos байрлалыг local space-с world space болгон байрлалыг буцаана</summary> public static Vector3 Pnt(Tf tf, Vector3 pos) { return(Matrix4x4.TRS(tf.t, tf.q, tf.s).MultiplyPoint3x4(pos)); }
/// <summary> /// Build the MNIST model up to where it may be used for inference. /// </summary> /// <param name="images">Images placeholder, from inputs()</param> /// <param name="hidden1Units">Size of the first hidden layer</param> /// <param name="hidden2Units">Size of the second hidden layer</param> /// <returns>softmax_linear: Output tensor with the computed logits</returns> public static object inference(Tensor <double> images, int hidden1Units, int hidden2Units) { // ReSharper disable once LocalVariableHidesMember const int NUM_CLASSES = 10; // ReSharper disable once LocalVariableHidesMember const int IMAGE_SIZE = 28; // ReSharper disable once LocalVariableHidesMember const int IMAGE_PIXELS = IMAGE_SIZE * IMAGE_SIZE; // Hidden 1 Tensor <double> hidden1, hidden2; using (var scope = Tf.NameScope("hidden1")) { var weights = Tf.Variable( Tf.TruncatedNormal(new[] { IMAGE_PIXELS, hidden1Units }, stddev: 1.0 / Math.Sqrt(IMAGE_PIXELS)), name: "weights"); var biases = Tf.Variable(Tf.ZerosDouble(new[] { hidden1Units }), name: "biases"); hidden1 = Tf.Nn.Relu(Tf.MatMul(images, weights) + biases); } // Hidden 2 using (var scope = Tf.NameScope("hidden2")) { var weights = Tf.Variable( Tf.TruncatedNormal(new[] { hidden1Units, hidden2Units }, stddev: 1.0 / Math.Sqrt(hidden1Units)), name: "weights"); var biases = Tf.Variable(Tf.ZerosDouble(new[] { hidden2Units }), name: "biases"); hidden2 = Tf.Nn.Relu(Tf.MatMul(hidden1, weights) + biases); } // Linear using (var scope = Tf.NameScope("softmax_linear")) { var weights = Tf.Variable( Tf.TruncatedNormal(new[] { hidden2Units, NUM_CLASSES }, stddev: 1.0 / Math.Sqrt(hidden2Units)), name: "weights"); var biases = Tf.Variable(Tf.ZerosDouble(new[] { NUM_CLASSES }), name: "biases"); var logits = Tf.MatMul(hidden2, weights) + biases; return(logits); } /* * * * """ # Hidden 1 # with tf.name_scope('hidden1'): # weights = tf.Variable ( # tf.truncated_normal([IMAGE_PIXELS, hidden1_units], # stddev=1.0 / math.sqrt(float(IMAGE_PIXELS))), # name='weights') # biases = tf.Variable(tf.zeros([hidden1_units]), # name='biases') # hidden1 = tf.nn.relu(tf.matmul(images, weights) + biases) # # # Hidden 2 # with tf.name_scope('hidden2'): # weights = tf.Variable( # tf.truncated_normal([hidden1_units, hidden2_units], # stddev=1.0 / math.sqrt(float(hidden1_units))), # name='weights') # biases = tf.Variable(tf.zeros([hidden2_units]), # name='biases') # hidden2 = tf.nn.relu(tf.matmul(hidden1, weights) + biases) # Linear # with tf.name_scope('softmax_linear'): # weights = tf.Variable( # tf.truncated_normal([hidden2_units, NUM_CLASSES], # stddev=1.0 / math.sqrt(float(hidden2_units))), # name='weights') # biases = tf.Variable(tf.zeros([NUM_CLASSES]), # name='biases') # logits = tf.matmul(hidden2, weights) + biases # return logits # * */ }
///<summary>mesh-р эргэлтийн бие үүсгэнэ</summary> public static void RotModel(ref Mesh mesh, bool isFill, bool isDisUv, int n, List <Vector2> points, Tf tf) { List <Vector2> lis = new List <Vector2>(points); if (isFill) { lis.Insert(0, V2.X(points[0], 0)); lis.Add(V2.X(points[points.Count - 1], 0)); } // vertices Vector3[] vs = new Vector3[n * lis.Count]; float dAng = 360f / n; for (int i = 0; i < lis.Count; i++) { for (int j = 0; j < n; j++) { vs[i * n + j] = Tf.Rot(tf.r, V3.Mul(new Vector3(lis[i].x * M.Cos(j * dAng), lis[i].y, lis[i].x * M.Sin(j * dAng)), tf.s)) + tf.t; } } // triangles int[] ts = new int[n * 6 * (lis.Count - 1)]; for (int i = 0; i < lis.Count - 1; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < 6; k++) { ts[n * 6 * i + j * 6 + k] = n * i + (j + UvUArr[k]) % n + UvVArr[k] * n; } } } // uv Vector3[] v = new Vector3[ts.Length]; int[] t = new int[ts.Length]; Vector2[] uv = new Vector2[ts.Length]; float du = 1f / n, dv = 1f / (lis.Count - 1); if (isDisUv) { float dis = 0, tmpDis, curDis = 0; List <float> disLis = new List <float>(); for (int i = 1; i < lis.Count; i++) { tmpDis = Vector3.Distance(lis[i - 1], lis[i]); disLis.Add(tmpDis); dis += tmpDis; } for (int i = 0; i < ts.Length; i++) { v[i] = vs[ts[i]]; t[i] = i; uv[i] = new Vector2( (i / 6 % n + UvUArr[i % 6]) * du, (curDis + UvVArr[i % 6] * disLis[i / 6 / n]) / dis ); if ((i + 1) % (6 * n) == 0) { curDis += disLis[i / 6 / n]; } } } else { for (int i = 0; i < ts.Length; i++) { v[i] = vs[ts[i]]; t[i] = i; uv[i] = new Vector2( (i / 6 % n + UvUArr[i % 6]) * du, (i / 6 / n + UvVArr[i % 6]) * dv ); } } // mesh VsTsUvRn(ref mesh, vs, ts, uv); }