Python List To Torch Tensor

CRF (num_tags, batch_first=False) [source] ¶. arange(-5,5) y = F. The following are code examples for showing how to use torch. This function converts Python objects of various types to Tensor objects. Think of it as just a fancy name for multi-dimensional matrices. Syntax: torch. retain_grad() # Since b is non-leaf and it's grad will be destroyed otherwise. Parameters. sinh() provides support for the hyperbolic sine function in PyTorch. 0: Variables are no longer necessary to use autograd with tensors. The function torch. Convolutional neural networks got their start by working with imagery. import sys import torch import torch. functional as F import torch. Metadata about each tensor is stored in model. Tensor(tensor) class torch. Support for developing full. It's mostly a mix of 3 pieces/ideas, Torch - Lua : A great computer vision and general compute framework with a fair amount of use in game development, and visualization. cpu for CPU; cuda:0 for putting it on GPU number 0. We provide an example below. To Create a 5x3 Tensor with values randomly selected from a Uniform Distribution between -1 and 1, torch. Since CUDA uses different programming models, the work to hide CUDA details is enormous. You can vote up the examples you like or vote down the ones you don't like. This function draws a line plot. new_ones(shape)). The preview release of PyTorch 1. item() for element in tensor. A tensor of arbitrary size. API documentation¶ class torchcrf. json with an index into this list. PyTorchの原型は「Torch(読み:トーチ)」と呼ばれる機械学習ライブラリです。Googleに買収されたDeepMind社もTensorFlow以前はTorchを利用していたと言われています。Torchは「Lua言語」で書かれていましたが、Pythonのサポートを行ったのがPyTorchです。. The data field refers to the file which contains the tensor storage data. OK, I Understand. The input type is tensor. TensorFlow has grown popular among developers over time. Support for developing full. A 2-dimensional tensor is a matrix that we're all familiar with, like bumpy arrays. This package can support useful features like loading different deep learning models, running them on gpu if available, loading/transforming images with multiprocessing and so on. PyTorch developers tuned this back-end code to run Python efficiently. Python中 list, numpy. Training our Neural Network. _TensorBase对象诞生了。 编辑于 2019-04-26 PyTorch. The python extension includes two main parts - MNN and MNNToools. size() gives a size object, but how do I convert it to ints? python pytorch tensor. Despite its simple interfaces, we need to understand its Tensor abstraction and those convenient helpers. NumPy, due to its excellent implementation of its core in C, runs a little bit faster than Tensor on CPU. The function torch. int) + torch. convert_to_tensor(arg, dtype=tf. Tensor()はデフォルトでtorch. device (torch. import torch a = torch. ones() var_tensor = torch. N should equal to n as well. Working with PyTorch tensors, I need to split the batch of items by its flags, so the items in x_batch_one and x_batch_two are lists of pairs that have the same flags. Tensor class torch. arange(-5,5) y = F. In version 1. Finally, just to make sure we've converted the PyTorch tensor to a list, we want to check three main things: (a) that it is a Python list, (b) that the nested list has preserved the tensor structure, and (c) that the numbers are still floating point numbers. PyTorch has made an impressive dent on the machine learning scene since Facebook open-sourced it in early 2017. 5) in earlier versions, this would've given a tensor with value 1 as the output. zeros upon initially creating the returned tensor. tensor([[13,14,15],[16,17,18]]) Again, we use torch. PyTorch installation in Linux is similar to the installation of Windows using Conda. seq_tensor = Variable(torch. A 2-dimensional tensor is a matrix that we're all familiar with, like bumpy arrays. It is used for deep neural network and natural language processing purposes. I've written some Python to create a pytorch tensor of random values, sampled from a Student's t distribution with 10 degrees of freedom: t = torch. reshape() Parameters. Run python command to work with python. By adopting tensors to express the operations of a neural network is useful for two a two-pronged purpose: both tensor calculus provides a very compact formalism and parallezing the GPU computation very easily. Convert scalar to torch Tensor. tensor and pass in more data. mapToBlocks (self: tensor_comprehensions. Next, I will explore the build system for PyTorch. copy – Whether to copy the memory. This function deserializes JSON, CSV, or NPY encoded data into a torch. 378 tensor: an n-dimensional `torch. The following are code examples for showing how to use torch. It takes a while. In this section please find the documentation for named tensor specific APIs. ParameterList: This will holds the parameters in a list. Here are five simple hands-on steps, to get started with Torch!. It accepts Tensor objects, numpy arrays, Python lists, and Python scalars. PyTorch tensors are instances of the torch. TensorFlow is an end-to-end open source platform for machine learning. In earlier versions, the output would’ve been 6. Tensor Comprehensions(TC) is a notation based on generalized Einstein notation for computing on multi-dimensional arrays. If you want to write your layers in C/C++, we provide a convenient extension API that is efficient and with minimal boilerplate. zeros upon initially creating the returned tensor. So now that we have our three example tensors initialized, let’s put them in a Python list. Tensor` 379 sparsity: The fraction of elements in each column to be set to zero 380 std: the standard deviation of the normal distribution used to generate. shape We can see that it is an empty list which signifies that it has zero dimensions. Module, so the function now can be easily used in models. shape (tuple of python:ints or int) – the desired shape. So we’re going to use the square bracket construction. Tensor(sequence) class torch. _namedtensor_internals import update_names, check_serializing_named_tensor, resolve_ellipsis from torch. Moving operators to C++ reduces the overhead and lowers the latency a single differentiable operation dispatched form Python to as few as 3. The default tensor type in PyTorch is a float tensor defined as torch. It expects the input in radian form and the output is in the range [-1, 1. The forward computation of this class computes the log likelihood of the given sequence of tags and emission score tensor. Tensor class torch. 5) in earlier versions, this would’ve given a tensor with value 1 as the output. This package can support useful features like loading different deep learning models, running them on gpu if available, loading/transforming images with multiprocessing and so on. nn as nn import torch. Tensor(size) class torch. nn as nn import torchvision. Tensor(sequence) class torch. A 0-dim tensor flattened is the same as a 1-dim tensor flattened. raw download clone embed report print Python 1. data (array_like) – Initial data for the tensor. from_numpy(boston. PyTorch tensors are instances of the torch. ones: a tensor with ones everywhere, torch. Model Paper; Convolutional Click Prediction Model [CIKM 2015]A Convolutional Click Prediction Model Factorization-supported Neural Network [ECIR 2016]Deep Learning over Multi-field Categorical Data: A Case Study on User Response Prediction. How do I check if a list is empty? How do I check whether a file exists without exceptions? How can I safely create a nested directory in Python? How do I sort a dictionary by value? How to make a chain of function decorators? How do I list all files of a directory? Pytorch reshape tensor dimension. tensor() call is the sort of go-to call, while torch. We assign it to the Python variable tensor_one. _namedtensor_internals import unzip_namedshape from collections import OrderedDict import torch. Like numpy's array, you can use torch. It's a container provided by PyTorch , which acts just like a Python list would. Moving operators to C++ reduces the overhead and lowers the latency a single differentiable operation dispatched form Python to as few as 3. 2017 Python最新面试题及答案16道题. Please use torch. Module objects corresponding in a Python list and then made the list a member of my nn. In this tutorial we have seen that TensorFlow is a powerful framework and makes it easy to work with several mathematical functions and multidimensional arrays, it also makes it easy to execute the data graphs and scaling. input_to_model (torch. The data field of a Tensor or a Parameter is where the actual values are and if you apply indexing to a Parameter or Tensor, the indexing is magically applied to the data field. Theano features: tight integration with NumPy – Use numpy. Unlike other frameworks which compile the graph first, and then execute the generated code, Chainer is all Python, and the graph is produced at run-time. WORLD): """Reduces the tensor data on multiple GPUs across all machines. NumPy Bridge ¶. "meaning you’ll be multiplying matrices and vectors. Tensor torch. In the actual pricing function we just need to replace np with torch and exchange the cdf function to use the PyTorch one and we have to convert our input into torch. static from_data_list (data_list, follow_batch=[]) [source] ¶ Constructs a batch object from a python list holding torch_geometric. abs()将会在一个新的tensor中计算结果。 class torch. To create a random tensor with specific shape, use torch. Tensors can come from either module parameters or Tensor type attributes. Step 6: Now, test PyTorch. They are extracted from open source Python projects. The function torch. Pre-trained models and datasets built by Google and the community. empty (5, 7, dtype = torch. We provide an example below. [quote][b]note: [/b]these binaries are built for ARM aarch64 architecture, so run these commands on a Jetson (not on a host PC)[/quote]UPDATE: check out our new torch2trt tool for converting. Tensor(1) will not give you a Tensor which contains. obj – The Python object to convert. hamiltorch: a PyTorch Python package for sampling What is hamiltorch?. They are extracted from open source Python projects. Metadata about each tensor is stored in model. a sound sample),. I'm not sure that these are included in the distributable wheel since that's intended for Python - so you may need to build following the instructions above, but with "python setup. nn as nn import torch. You can vote up the examples you like or vote down the ones you don't like. Tensor 格式相互转化 2. In this deep learning with Python and Pytorch tutorial, we'll be actually training this neural network by learning how to iterate over our data, pass to the model, calculate loss from the result, and then do backpropagation to. The python needs to be installed in dev. omit_useless_nodes - Default to true, which eliminates unused nodes. sum (dim, keepdim = keepdim)). This repo contains model definitions in this functional way, with pretrained weights for. I want to create a 1d torch tensor that will contain all those values. Array interpretation of a. SUM, group = group. This page documents these convenience imports, which are defined in fastai. Friends and users of our open-source tools are often surprised how fast 🚀 we reimplement the latest SOTA pre-trained TensorFlow models to make them accessible for everyone in our libraries like. In the actual pricing function we just need to replace np with torch and exchange the cdf function to use the PyTorch one and we have to convert our input into torch. ones(1, requires_grad=True); x. 이 글에서는 PyTorch 프로젝트를 만드는 방법에 대해서 알아본다. Not really a list, it's a tensor, but hopefully you understand what I mean. hwc_tensor = torch. zeros_like(other): a tensor with the same shape as other and zeros everywhere, torch. This function is also provided by the treelstm. reshape() Parameters. The following are code examples for showing how to use torch. tensor() call is the sort of go-to call, while torch. Tensor(list) 2. It must either return None or a Tensor which will be used in place of grad for further gradient computation. tensor(number) 3. Tensor torch. In this example, we’re going to specifically use the float tensor operation because we want to point out that we are using a Python list full of floating point numbers. 创建scalar的话,需要用torch. float32 objects leaks memory. range and torch. The number of elements in the delta tensor is equal to: n_samples * input. PyTorchの原型は「Torch(読み:トーチ)」と呼ばれる機械学習ライブラリです。Googleに買収されたDeepMind社もTensorFlow以前はTorchを利用していたと言われています。Torchは「Lua言語」で書かれていましたが、Pythonのサポートを行ったのがPyTorchです。. dtype, optional) - the desired data type of returned tensor. It takes a while. LongTensor(). PyTorch has made an impressive dent on the machine learning scene since Facebook open-sourced it in early 2017. tensor(5) + 1. It must either return None or a Tensor which will be used in place of grad for further gradient computation. Unlike other frameworks which compile the graph first, and then execute the generated code, Chainer is all Python, and the graph is produced at run-time. mapToBlocks (self: tensor_comprehensions. MNN provide python extension as well as C++. This below example was not allowed in version 1. Each tensor type corresponds to the type of number (and more importantly the size/preision of the number) contained in each place of the matrix. [quote][b]note: [/b]these binaries are built for ARM aarch64 architecture, so run these commands on a Jetson (not on a host PC)[/quote]UPDATE: check out our new torch2trt tool for converting. One of PyTorch's key features (and what makes it a deep learning library) is the ability to specify arbitrary computation graphs and compute gradients on them automatically. PyTorch pretrained bert can be installed by pip as follows:. Tensor(i) for i in a]). To paraphrase Paul Graham:. tensor() call is the sort of go-to call, while torch. Parallelism: torch. parameterDict: This will holds the parameters in a directory. Next, I will explore the build system for PyTorch. Default is numpy. type(pt_tensor_from_list) Next, let's check to see the data type of the data inside of the tensor by using the PyTorch dtype operator. Tensor object represents a partially defined computation that will eventually produce a value. Some things to keep in mind (memory sharing works where it can):. Define an input tensor x with value 1 and tell pytorch that I want it to track the gradients of x. NumPy, due to its excellent implementation of its core in C, runs a little bit faster than Tensor on CPU. other (torch. The function torch. Tensor(sequence) class torch. 例如,当我们引用torch时,Torch脚本编译器实际上在声明函数时将其解析为Python的torch模块。这些Python值不是Torch脚本的一部分,它们在编译时被转换成Torch脚本支持的原始类型。本节介绍在Torch脚本中访问Python值时使用的规则。它们依赖于引用的python值的动态类型。. set_default_tensor_type()により型を変更することはできるが型が浮動小数点のみとなっている。そのため、torch. They are extracted from open source Python projects. Originally, PyTorch was developed by Hugh Perkins as a Python wrapper for the LusJIT based on Torch framework. Preparing a Model for Quantization Background. Use the list below to select a version to view. class torch. 类似numpy的ndarrays,强化了可进行GPU计算的特性,由C拓展模块实现。如上面的torch. Strange Loop (Sept 12-14, 2019 - St. Can be a list, tuple, NumPy ndarray, scalar, and other types. 15个重要Python面试题 测测你适不适合做Python? torch. newaxis in a torch Tensor to increase the dimension. To create a tensor object from a Python list, you call torch. module load python ), you must use the python installation in the container for PyTorch. In this tutorial we have seen that TensorFlow is a powerful framework and makes it easy to work with several mathematical functions and multidimensional arrays, it also makes it easy to execute the data graphs and scaling. sin() provides support for the sine function in PyTorch. 8390, grad_fn=) Note that the returned value is the log likelihood so you’ll need to make this value negative as your loss. Tensor) - **kwargs - Keyword arguments passed to torch. PyTorch provides the torch. set_default_dtype(d) 将d设置为默认浮点类型(dtype). Let's print the tensor_one Python variable to see what we have. transforms as transforms import torch. tensor on a Python list of np. We then create the next Variable called y. Tensor object represents a partially defined computation that will eventually produce a value. 사용되는 torch 함수들의 사용법은 여기에서 확인할 수 있다. Working with PyTorch tensors, I need to split the batch of items by its flags, so the items in x_batch_one and x_batch_two are lists of pairs that have the same flags. The function torch. We will go over the dataset preparation, data augmentation and then steps to build the classifier. The function torch. 1 list 转 torch. This repo contains model definitions in this functional way, with pretrained weights for. FloatTensor. You can vote up the examples you like or vote down the ones you don't like. if and for vs theano. How do I convert a PyTorch Tensor into a python list? My current use case is to convert a tensor of size [1, 2048, 1, 1] into a list of 2048 elements. To anchor deep national capabilities in Artificial Intelligence, thereby creating social and economic impacts, grow local talent, build an AI ecosystem and put Singapore on the world map. Python中 list, numpy. Each tensor type corresponds to the type of number (and more importantly the size/preision of the number) contained in each place of the matrix. When we create a torch. The input type is tensor and if the input contains more than one element, element-wise hyperbolic cosine is computed. PyTorch is just such a great framework for deep learning that you needn't be afraid to stray off the beaten path of pre-made networks and higher-level libraries like fastai. To use the PyTorch python package, you must load the appropriate environmental module (e. array(python_list). reshape(input. import torch. In pytorch, V. Run python command to work with python. [quote][b]note: [/b]these binaries are built for ARM aarch64 architecture, so run these commands on a Jetson (not on a host PC)[/quote]UPDATE: check out our new torch2trt tool for converting. While PyTorch follows Torch’s naming convention and refers to multidimensional matrices as “tensors”, Apache MXNet follows NumPy’s conventions and refers to them as “NDArrays”. The following are code examples for showing how to use torch. This determines the optimization level of the graph. [quote][b]note: [/b]these binaries are built for ARM aarch64 architecture, so run these commands on a Jetson (not on a host PC)[/quote]UPDATE: check out our new torch2trt tool for converting. rand() function returns tensor with random values generated in the specified shape. A series of tests is included for the library and the example scripts. Finally, just to make sure we've converted the PyTorch tensor to a list, we want to check three main things: (a) that it is a Python list, (b) that the nested list has preserved the tensor structure, and (c) that the numbers are still floating point numbers. In this note I'll introduce some core concepts for quantized Tensor and list the current user facing API in Python. Tensor objects that are created from NumPy ndarray objects, share memory. TensorFlow has grown popular among developers over time. " TensorFlow offers ops for low-level operations, and from the beginning programmers used those low-level ops to build higher-level APIs. In the first post I explained how we generate a torch. hwc_tensor = torch. pt_tensor_from_list = torch. _C as _C from torch. 但注意 item() 只适用于 tensor 只包含一个元素的时候。因为大多数情况下我们的 loss 就只有一个元素,所以就经常会用到 loss. Installation on Linux. shape[0] In order to get a example-based delta, we can, for example, average them: deltas_per_example = torch. For example,torch. This function deserializes JSON, CSV, or NPY encoded data into a torch. shape > torch. The python extension includes two main parts - MNN and MNNToools. tensor(list)也可以进行创建tensor. Array interpretation of a. It takes as input an N or NxM tensor Y that specifies the values of the M lines (that connect N points) to plot. This will holds sub-modules in a list. Every Tensor in PyTorch has a to() member function. { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type. Size([10]) Matrices Most of the structured data is usually represented in the form of tables or a specific matrix. *Tensor of range [0, 1] and shape C x H x W or numpy ndarray of dtype=uint8, range[0, 255] and shape H x W x C to a PIL. 5) in earlier versions, this would’ve given a tensor with value 1 as the output. item() So we have our tensor, then we’re going to use the item operation, and we’re going to assign the value returned to the Python variable converted_python_number. Is there a list about which syntax is recommended, which is not? Some numpy-like syntax is more popular for user, but not recommended. In order for those blocks to be detected, we need to use torch. TensorDataset(). Default NPY deserialization requires request_body to follow the NPY format. A tensor is a generalized matrix, a nite table of numerical values indexed along several discrete dimensions. 全ての要素がlistで完結しているなら何も問題はないと思いますが、tensor in list -> tensorsの際にひっかかったため なお、list内のtensorは全て同じshapeを持つとします. uint8) >>> model (emissions, tags, mask = mask) tensor(-10. API documentation¶ class torchcrf. The function torch. Every Tensor in PyTorch has a to() member function. float32 objects leaks memory. script_method to find the frontend that compiles the Python code into PyTorch's tree views, and. new_ones(shape)). Module objects corresponding in a Python list and then made the list a member of my nn. Here are five simple hands-on steps, to get started with Torch!. python language, tutorials, tutorial, python, programming, development, python modules, python module. Tensor) - The result tensor has the same shape as other. For example, a tensor with dimension (or rank in TensorFlow speak) 0 is a scalar, rank 1 a vector, rank 2 a matrix and so on. Tensorへの操作は基本的にVariableで包んだ後でも使えます。 とりあえず最低限ココラヘンを知っていれば、あとはPythonの操作と組み合わせていろいろできると思います。. import sys import torch import torch. as_list() gives a list of integers of the dimensions of V. from_numpy(boston. The function is not supposed modify it's argument. 7us for tensor operation. solve and will be removed in the " 279 "next release. PyTorch installation in Linux is similar to the installation of Windows using Conda. Tensor(tensor) class torch. 0 y = torch. index_select()选择特定索引 选择特定下标有时候很有用,比如上面的a这个Tensor可以看作4张RGB(3通道)的MNIST图像,长宽都是28px。. This function draws a line plot. tensor(0); a. Tensor Python class. 3 and I'm trying to install PyTorch. static from_data_list (data_list, follow_batch=[]) [source] ¶ Constructs a batch object from a python list holding torch_geometric. In the first post I explained how we generate a torch. squeeze() Returns a tensor with all the dimensions of input of size 1 removed. _six import imap from. The fact-checkers, whose work is more and more important for those who prefer facts over lies, police the line between fact and falsehood on a day-to-day basis, and do a great job. Today, my small contribution is to pass along a very good overview that reflects on one of Trump’s favorite overarching falsehoods. Namely: Trump describes an America in which everything was going down the tubes under  Obama, which is why we needed Trump to make America great again. And he claims that this project has come to fruition, with America setting records for prosperity under his leadership and guidance. “Obama bad; Trump good” is pretty much his analysis in all areas and measurement of U.S. activity, especially economically. Even if this were true, it would reflect poorly on Trump’s character, but it has the added problem of being false, a big lie made up of many small ones. Personally, I don’t assume that all economic measurements directly reflect the leadership of whoever occupies the Oval Office, nor am I smart enough to figure out what causes what in the economy. But the idea that presidents get the credit or the blame for the economy during their tenure is a political fact of life. Trump, in his adorable, immodest mendacity, not only claims credit for everything good that happens in the economy, but tells people, literally and specifically, that they have to vote for him even if they hate him, because without his guidance, their 401(k) accounts “will go down the tubes.” That would be offensive even if it were true, but it is utterly false. The stock market has been on a 10-year run of steady gains that began in 2009, the year Barack Obama was inaugurated. But why would anyone care about that? It’s only an unarguable, stubborn fact. Still, speaking of facts, there are so many measurements and indicators of how the economy is doing, that those not committed to an honest investigation can find evidence for whatever they want to believe. Trump and his most committed followers want to believe that everything was terrible under Barack Obama and great under Trump. That’s baloney. Anyone who believes that believes something false. And a series of charts and graphs published Monday in the Washington Post and explained by Economics Correspondent Heather Long provides the data that tells the tale. The details are complicated. Click through to the link above and you’ll learn much. But the overview is pretty simply this: The U.S. economy had a major meltdown in the last year of the George W. Bush presidency. Again, I’m not smart enough to know how much of this was Bush’s “fault.” But he had been in office for six years when the trouble started. So, if it’s ever reasonable to hold a president accountable for the performance of the economy, the timeline is bad for Bush. GDP growth went negative. Job growth fell sharply and then went negative. Median household income shrank. The Dow Jones Industrial Average dropped by more than 5,000 points! U.S. manufacturing output plunged, as did average home values, as did average hourly wages, as did measures of consumer confidence and most other indicators of economic health. (Backup for that is contained in the Post piece I linked to above.) Barack Obama inherited that mess of falling numbers, which continued during his first year in office, 2009, as he put in place policies designed to turn it around. By 2010, Obama’s second year, pretty much all of the negative numbers had turned positive. By the time Obama was up for reelection in 2012, all of them were headed in the right direction, which is certainly among the reasons voters gave him a second term by a solid (not landslide) margin. Basically, all of those good numbers continued throughout the second Obama term. The U.S. GDP, probably the single best measure of how the economy is doing, grew by 2.9 percent in 2015, which was Obama’s seventh year in office and was the best GDP growth number since before the crash of the late Bush years. GDP growth slowed to 1.6 percent in 2016, which may have been among the indicators that supported Trump’s campaign-year argument that everything was going to hell and only he could fix it. During the first year of Trump, GDP growth grew to 2.4 percent, which is decent but not great and anyway, a reasonable person would acknowledge that — to the degree that economic performance is to the credit or blame of the president — the performance in the first year of a new president is a mixture of the old and new policies. In Trump’s second year, 2018, the GDP grew 2.9 percent, equaling Obama’s best year, and so far in 2019, the growth rate has fallen to 2.1 percent, a mediocre number and a decline for which Trump presumably accepts no responsibility and blames either Nancy Pelosi, Ilhan Omar or, if he can swing it, Barack Obama. I suppose it’s natural for a president to want to take credit for everything good that happens on his (or someday her) watch, but not the blame for anything bad. Trump is more blatant about this than most. If we judge by his bad but remarkably steady approval ratings (today, according to the average maintained by 538.com, it’s 41.9 approval/ 53.7 disapproval) the pretty-good economy is not winning him new supporters, nor is his constant exaggeration of his accomplishments costing him many old ones). I already offered it above, but the full Washington Post workup of these numbers, and commentary/explanation by economics correspondent Heather Long, are here. On a related matter, if you care about what used to be called fiscal conservatism, which is the belief that federal debt and deficit matter, here’s a New York Times analysis, based on Congressional Budget Office data, suggesting that the annual budget deficit (that’s the amount the government borrows every year reflecting that amount by which federal spending exceeds revenues) which fell steadily during the Obama years, from a peak of $1.4 trillion at the beginning of the Obama administration, to $585 billion in 2016 (Obama’s last year in office), will be back up to $960 billion this fiscal year, and back over $1 trillion in 2020. (Here’s the New York Times piece detailing those numbers.) Trump is currently floating various tax cuts for the rich and the poor that will presumably worsen those projections, if passed. As the Times piece reported: